:root {
  --ink: #20304a;
  --muted: #66758c;
  --primary: #4f7cff;
  --primary-dark: #3157c8;
  --danger: #d83b54;
  --surface: rgba(255, 255, 255, 0.94);
  --surface-strong: #ffffff;
  --line: rgba(36, 61, 101, 0.14);
  --shadow: 0 18px 50px rgba(36, 70, 120, 0.15);
  --radius: 28px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background-attachment: fixed;
  line-height: 1.55;
}

body.font-rounded { font-family: ui-rounded, "Arial Rounded MT Bold", "Trebuchet MS", Arial, sans-serif; }
body.font-classic { font-family: Georgia, "Times New Roman", serif; }
body.font-comic { font-family: "Comic Sans MS", "Trebuchet MS", cursive, sans-serif; }
body.font-mono { font-family: "Courier New", Consolas, monospace; }
body.font-friendly { font-family: "Trebuchet MS", Arial, sans-serif; font-size: 1.08rem; }

body.theme-sky {
  background-color: #dff2ff;
  background-image: radial-gradient(circle at 15% 12%, rgba(255,255,255,.95) 0 4%, transparent 4.3%), radial-gradient(circle at 70% 16%, rgba(255,255,255,.8) 0 6%, transparent 6.3%), linear-gradient(145deg, #b8e4ff, #f7fbff 52%, #d9f5ff);
}
body.theme-space {
  --ink: #eef4ff; --muted: #bec9dc; --surface: rgba(18, 24, 48, .9); --surface-strong: #17203c; --line: rgba(255,255,255,.13);
  background-color: #081126;
  background-image: radial-gradient(circle at 20% 20%, rgba(128,98,255,.5), transparent 25%), radial-gradient(circle at 80% 10%, rgba(41,175,255,.4), transparent 25%), radial-gradient(circle at 50% 90%, rgba(255,74,178,.25), transparent 35%), repeating-radial-gradient(circle at 20% 30%, #fff 0 1px, transparent 1px 70px);
}
body.theme-candy {
  background-color: #fff0fa;
  background-image: radial-gradient(circle at 15% 20%, rgba(255,118,174,.28), transparent 22%), radial-gradient(circle at 80% 15%, rgba(151,105,255,.22), transparent 24%), radial-gradient(circle at 50% 85%, rgba(68,207,204,.22), transparent 26%), linear-gradient(135deg, #fff1f8, #f6f1ff);
}
body.theme-jungle {
  --ink: #17392d; --primary: #2b9b68; --primary-dark: #176e48;
  background-color: #dbf2dc;
  background-image: radial-gradient(circle at 10% 15%, rgba(47,143,88,.25), transparent 25%), radial-gradient(circle at 90% 18%, rgba(139,196,73,.3), transparent 24%), linear-gradient(145deg, #cbe9c5, #eef8df 55%, #d4f4e0);
}
body.theme-ocean {
  --primary: #087ac2; --primary-dark: #045c95;
  background-color: #dff8ff;
  background-image: radial-gradient(circle at 85% 15%, rgba(42,182,221,.33), transparent 22%), repeating-radial-gradient(ellipse at 50% 105%, rgba(255,255,255,.65) 0 12px, rgba(76,185,224,.17) 13px 24px, transparent 25px 70px), linear-gradient(#c9f1ff, #edfaff 50%, #cceefa);
}
body.theme-sunset {
  --primary: #f06b43; --primary-dark: #c4482e;
  background-color: #ffe8d1;
  background-image: radial-gradient(circle at 75% 15%, rgba(255,238,128,.92) 0 7%, transparent 7.4%), linear-gradient(155deg, #ffb385 0%, #ffd3be 40%, #f5c6ef 72%, #b9c7ff 100%);
}

body.cards-square { --radius: 12px; }
body.cards-glass { --surface: rgba(255,255,255,.6); --surface-strong: rgba(255,255,255,.72); }
body.theme-space.cards-glass { --surface: rgba(16,24,53,.62); --surface-strong: rgba(20,31,65,.74); }

button, input, textarea, select { font: inherit; }
a { color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: 72px;
  padding: 12px clamp(16px, 4vw, 50px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  font-weight: 900;
  font-size: clamp(1.1rem, 2.4vw, 1.45rem);
}
.brand-star { color: #ffc72c; font-size: 1.4em; filter: drop-shadow(0 2px 2px rgba(0,0,0,.12)); }
.main-nav { display: flex; align-items: center; gap: 5px; }
.main-nav a, .nav-link-button {
  border: 0;
  background: transparent;
  color: var(--ink);
  text-decoration: none;
  padding: 10px 12px;
  border-radius: 14px;
  cursor: pointer;
  font-weight: 800;
}
.main-nav a:hover, .main-nav a.active, .nav-link-button:hover { background: rgba(79,124,255,.13); }
.main-nav form { margin: 0; }
.nav-toggle { display: none; border: 0; background: transparent; font-size: 1.7rem; color: var(--ink); }

.page-shell { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 42px 0 70px; min-height: calc(100vh - 135px); }
.site-footer { text-align: center; padding: 24px; color: var(--muted); font-weight: 700; }

.hero-panel, .page-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 28px;
}
.hero-panel {
  position: relative;
  overflow: hidden;
  padding: clamp(30px, 6vw, 62px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.hero-panel::after { content: ''; position: absolute; inset: auto -60px -80px auto; width: 240px; height: 240px; border-radius: 50%; background: rgba(79,124,255,.12); }
.hero-panel h1, .page-title-row h1 { margin: 0; line-height: 1.12; font-size: clamp(2rem, 5vw, 4rem); }
.hero-emoji { font-size: clamp(4rem, 12vw, 8rem); transform: rotate(6deg); z-index: 1; }
.page-title-row { align-items: flex-end; }
.page-title-row p { margin-bottom: 0; color: var(--muted); }
.page-title-emoji { font-size: 4rem; }
.eyebrow { margin: 0 0 7px; color: var(--primary); font-size: .84rem; letter-spacing: .16em; text-transform: uppercase; font-weight: 900; }
.section-heading { margin: 34px 0 18px; }
.section-heading h2 { margin: 0; font-size: 1.8rem; }
.section-heading p { margin: 3px 0 0; color: var(--muted); }

.feature-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.feature-grid.admin-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.feature-card {
  position: relative;
  min-height: 250px;
  padding: 30px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-decoration: none;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform .2s ease, box-shadow .2s ease;
}
.feature-card:hover { transform: translateY(-5px) rotate(-.2deg); box-shadow: 0 24px 60px rgba(36,70,120,.22); }
.feature-card::after { content: ''; position: absolute; width: 150px; height: 150px; border-radius: 50%; right: -45px; bottom: -55px; background: rgba(79,124,255,.09); }
.feature-card h2 { margin: 16px 0 6px; font-size: 1.8rem; }
.feature-card p { margin: 0 0 25px; color: var(--muted); max-width: 34rem; }
.feature-icon { font-size: 3rem; line-height: 1; }
.card-action { margin-top: auto; color: var(--primary); font-weight: 900; }
.game-card { background-image: linear-gradient(145deg, var(--surface), rgba(105,195,255,.2)); }
.typing-card { background-image: linear-gradient(145deg, var(--surface), rgba(255,146,199,.2)); }
.admin-card { background-image: linear-gradient(145deg, var(--surface), rgba(255,213,96,.2)); }
.disabled-card { opacity: .7; }
.status-pill { display: inline-block; padding: 5px 10px; border-radius: 999px; background: #ffe3a3; color: #6d4a00; font-weight: 800; font-size: .85rem; }

.content-card, .auth-card, .reading-page {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.content-card { padding: clamp(22px, 4vw, 36px); }
.content-card h2:first-child { margin-top: 0; }
.narrow-card { max-width: 650px; }
.two-column-layout { display: grid; grid-template-columns: minmax(280px, .75fr) minmax(0, 1.4fr); gap: 24px; align-items: start; }
.sticky-card { position: sticky; top: 95px; }

.stack-form { display: grid; gap: 18px; }
label { display: grid; gap: 7px; font-weight: 800; }
input, textarea, select {
  width: 100%;
  border: 2px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  background: var(--surface-strong);
  color: var(--ink);
  outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(79,124,255,.12); }
textarea { resize: vertical; }
.check-row { display: flex; align-items: center; gap: 10px; }
.check-row input { width: 22px; height: 22px; accent-color: var(--primary); }

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: fit-content;
  border: 0;
  border-radius: 14px;
  padding: 11px 17px;
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
  background: #e8eefb;
  color: #213454;
  transition: transform .12s ease, filter .12s ease;
}
.button:hover { transform: translateY(-1px); filter: brightness(.98); }
.button-primary { background: var(--primary); color: white; box-shadow: 0 10px 20px rgba(64,102,210,.24); }
.button-secondary { background: var(--surface); border: 1px solid var(--line); color: var(--ink); }
.button-danger { background: #ffe2e7; color: #9e1830; }
.button-big { padding: 14px 22px; font-size: 1.07rem; }
.button-small { padding: 8px 12px; font-size: .9rem; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.button-row form { margin: 0; }

.auth-wrap { min-height: 68vh; display: grid; place-items: center; }
.auth-card { width: min(480px, 100%); padding: clamp(28px, 6vw, 48px); text-align: center; }
.auth-card h1 { margin: 8px 0; font-size: clamp(2rem, 7vw, 3.2rem); }
.auth-card > p { color: var(--muted); }
.auth-card .stack-form { text-align: left; margin-top: 25px; }
.auth-card .button { width: 100%; }
.auth-mascot { font-size: 4.5rem; }
.setup-note { font-size: .9rem; margin-top: 25px; }

.flash { margin: 0 0 22px; padding: 13px 16px; border-radius: 14px; font-weight: 800; }
.flash-success { color: #175b3d; background: #dff7e9; border: 1px solid #a6dfbd; }
.flash-error { color: #8d1e32; background: #ffe6eb; border: 1px solid #ffc1ce; }

.user-list { display: grid; gap: 14px; }
.user-row { border: 1px solid var(--line); border-radius: 18px; padding: 16px; background: var(--surface-strong); }
.user-main { display: flex; align-items: center; gap: 12px; }
.avatar-circle { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 50%; background: linear-gradient(135deg, #7ac4ff, #856eff); color: white; font-size: 1.2rem; font-weight: 900; }
.muted { color: var(--muted); font-size: .9rem; }
details { margin-top: 12px; }
summary { cursor: pointer; color: var(--primary); font-weight: 900; }
.account-tools { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; padding-top: 12px; }
.inline-form { display: flex; gap: 8px; flex: 1 1 280px; }
.inline-form input { min-width: 120px; }

.settings-layout { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(300px, .8fr); gap: 26px; align-items: start; }
.settings-controls { display: grid; gap: 24px; }
fieldset { border: 0; padding: 0; margin: 0; }
legend { font-weight: 900; margin-bottom: 10px; font-size: 1.05rem; }
.choice-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.visual-choice, .text-choice { cursor: pointer; }
.visual-choice input, .text-choice input, .mood-grid input, .post-theme-picker input { position: absolute; opacity: 0; pointer-events: none; }
.visual-choice span, .text-choice span { display: grid; place-items: center; min-height: 70px; padding: 10px; border: 3px solid transparent; border-radius: 16px; background: var(--surface-strong); text-align: center; }
.visual-choice b { font-size: 1.7rem; }
.visual-choice input:checked + span, .text-choice input:checked + span { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,124,255,.14); }
.theme-swatch-sky span { background: linear-gradient(135deg,#c3eaff,#fff); }
.theme-swatch-space span { background: linear-gradient(135deg,#101939,#6246a8); color:#fff; }
.theme-swatch-candy span { background: linear-gradient(135deg,#ffd5e8,#e5d8ff); }
.theme-swatch-jungle span { background: linear-gradient(135deg,#bfe5b8,#eff9d5); }
.theme-swatch-ocean span { background: linear-gradient(135deg,#bfefff,#e9fbff); }
.theme-swatch-sunset span { background: linear-gradient(135deg,#ffb98c,#d8bdff); }
.font-sample-rounded { font-family: ui-rounded, "Arial Rounded MT Bold", Arial, sans-serif; }
.font-sample-classic { font-family: Georgia, serif; }
.font-sample-comic { font-family: "Comic Sans MS", cursive; }
.font-sample-mono { font-family: "Courier New", monospace; }
.font-sample-friendly { font-family: "Trebuchet MS", sans-serif; font-size: 1.08rem; }
.preview-stage { position: sticky; top: 96px; padding: 20px; min-height: 540px; border-radius: var(--radius); display: grid; place-items: center; background: linear-gradient(145deg,#cbeaff,#f7fbff); transition: all .2s ease; }
.preview-browser { width: 100%; min-height: 400px; overflow: hidden; border-radius: 20px; background: rgba(255,255,255,.9); color: #24324a; box-shadow: 0 22px 55px rgba(0,0,0,.16); }
.preview-dots { padding: 10px 15px; color: #f06f81; letter-spacing: 4px; border-bottom: 1px solid rgba(0,0,0,.08); }
.preview-brand { padding: 14px 20px; font-weight: 900; }
.preview-content { padding: 34px 22px; }
.preview-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 24px; }
.preview-cards div { padding: 24px 10px; text-align: center; background: white; border-radius: 20px; box-shadow: 0 8px 25px rgba(0,0,0,.08); }

.game-admin-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.game-admin-card { display: grid; gap: 17px; }
.game-admin-icon { font-size: 3rem; }
.game-page { display: grid; justify-items: center; gap: 24px; }
.game-header { width: 100%; display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; }
.game-header h1 { font-size: clamp(2.2rem, 6vw, 4rem); margin: 6px 0; }
.game-header p { margin: 0; color: var(--muted); }
.back-link { color: var(--primary); font-weight: 900; text-decoration: none; }
.game-status { padding: 12px 20px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); font-size: 1.15rem; font-weight: 900; box-shadow: 0 8px 25px rgba(0,0,0,.08); }
.ttt-board { width: min(520px, 100%); aspect-ratio: 1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(3, minmax(0, 1fr)); gap: 12px; padding: 16px; border-radius: 32px; background: rgba(30,87,181,.85); box-shadow: var(--shadow); }
.ttt-cell { min-width: 0; min-height: 0; width: 100%; height: 100%; padding: 0; display: grid; place-items: center; overflow: hidden; border: 0; border-radius: 20px; background: #fff; color: #22385b; cursor: pointer; font-size: clamp(3rem, 12vw, 7rem); font-weight: 900; line-height: 1; }
.ttt-cell.x { color: #ef4f67; }
.ttt-cell.o { color: #2d87e8; }
.ttt-cell.winner { animation: winnerPulse .7s ease infinite alternate; background: #fff3a6; }
@keyframes winnerPulse { to { transform: scale(.92); } }
.score-strip { display: grid; grid-template-columns: repeat(3,1fr); gap: 12px; width: min(520px, 92vw); }
.score-strip div { display: grid; place-items: center; padding: 14px; background: var(--surface); border-radius: 18px; border: 1px solid var(--line); }
.score-strip strong { font-size: 1.5rem; }
.score-strip span { color: var(--muted); font-size: .85rem; }
.connect-board-wrap { width: min(720px, 100%); }
.connect-drop-buttons { display: grid; grid-template-columns: repeat(7,1fr); gap: 5px; padding: 0 14px 8px; }
.connect-drop-buttons button { border: 0; background: transparent; color: var(--primary); cursor: pointer; font-size: clamp(1.2rem,4vw,2rem); }
.connect-board { display: grid; grid-template-columns: repeat(7,1fr); gap: 8px; padding: 16px; border-radius: 28px; background: #1764c0; box-shadow: var(--shadow); }
.connect-cell { aspect-ratio: 1; border-radius: 50%; background: #0b4a94; display: grid; place-items: center; padding: 7px; }
.connect-cell span { width: 100%; height: 100%; border-radius: 50%; background: #f5f9ff; box-shadow: inset 0 4px 8px rgba(0,0,0,.18); transition: transform .18s ease; }
.connect-cell.red span { background: #f0444e; }
.connect-cell.yellow span { background: #ffd62f; }
.connect-cell.win span { animation: winnerPulse .7s ease infinite alternate; box-shadow: 0 0 0 5px #fff, 0 0 24px #fff; }

.post-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 22px; }
.post-card { position: relative; min-height: 260px; padding: 26px; display: flex; flex-direction: column; text-decoration: none; color: #26344d; border-radius: var(--radius); border: 1px solid rgba(0,0,0,.08); box-shadow: var(--shadow); transition: transform .2s ease; overflow: hidden; }
.post-card:hover { transform: translateY(-5px) rotate(.2deg); }
.post-mood { font-size: 3.3rem; }
.post-card h2 { margin: 12px 0 8px; font-size: 1.7rem; }
.post-card p { color: #526075; }
.post-card-body { flex: 1; }
.post-meta { display: flex; justify-content: space-between; gap: 12px; margin-top: 18px; font-size: .84rem; font-weight: 800; color: #596377; }
.post-theme-sunny { background: linear-gradient(145deg,#fff9c6,#ffe79b); }
.post-theme-ocean { background: linear-gradient(145deg,#d8f5ff,#9edcff); }
.post-theme-berry { background: linear-gradient(145deg,#ffe2f0,#ffc0da); }
.post-theme-mint { background: linear-gradient(145deg,#e3ffe8,#baf1c9); }
.post-theme-purple { background: linear-gradient(145deg,#eee6ff,#d7c3ff); }
.post-theme-rainbow { background: linear-gradient(135deg,#ffe3e3,#fff3b8,#d7ffd9,#d8edff,#eadcff); }
.reading-page { max-width: 900px; margin: 0 auto; padding: clamp(25px,6vw,64px); color: #24324a; }
.reading-topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.reading-header { text-align: center; margin: 35px auto 45px; }
.reading-mood { font-size: 5rem; }
.reading-header h1 { margin: 8px 0; font-size: clamp(2.2rem,7vw,4.6rem); line-height: 1.06; }
.reading-header p { color: #59667a; }
.rich-content { font-size: 1.15rem; }
.rich-content h1 { font-size: 2.6rem; }
.rich-content h2 { font-size: 2rem; }
.rich-content h3 { font-size: 1.4rem; }
.rich-content img { display: block; max-width: 100%; height: auto; margin: 24px auto; border-radius: 20px; box-shadow: 0 12px 28px rgba(0,0,0,.14); }
.rich-content blockquote { margin: 20px 0; padding: 14px 20px; border-left: 6px solid #7d67e8; background: rgba(255,255,255,.55); border-radius: 10px; }
.rich-content a { color: #205ab7; font-weight: 800; }
.rich-content .sticker { display: inline-block; font-size: 4rem; line-height: 1; margin: 6px; }

.editor-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(280px, .6fr); gap: 24px; align-items: start; }
.editor-main { min-width: 0; }
.title-input-label { margin-bottom: 18px; }
.title-input { font-size: 1.4rem; font-weight: 900; }
.editor-toolbar { display: flex; flex-wrap: wrap; gap: 7px; padding: 10px; border: 1px solid var(--line); border-bottom: 0; border-radius: 16px 16px 0 0; background: rgba(232,239,251,.8); }
.editor-toolbar button, .editor-toolbar select, .toolbar-upload, .colour-tool { width: auto; min-height: 38px; padding: 7px 10px; border: 1px solid rgba(0,0,0,.1); border-radius: 10px; background: #fff; color: #26344d; font-weight: 800; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; }
.editor-toolbar select { max-width: 155px; }
.colour-tool input { width: 26px; height: 24px; padding: 0; border: 0; }
.emoji-tray { display: flex; flex-wrap: wrap; gap: 5px; align-items: center; padding: 10px; background: rgba(255,255,255,.72); border-inline: 1px solid var(--line); }
.emoji-tray > span { font-size: .82rem; color: var(--muted); font-weight: 900; margin-left: 4px; }
.emoji-tray button { border: 0; background: transparent; font-size: 1.35rem; cursor: pointer; border-radius: 8px; }
.emoji-tray button:hover { background: rgba(79,124,255,.14); transform: scale(1.12); }
.emoji-tray .sticker-button { font-size: 1.8rem; }
.rich-editor { min-height: 460px; padding: 24px; border: 2px solid var(--line); border-radius: 0 0 16px 16px; outline: none; background: var(--surface-strong); color: var(--ink); font-size: 1.1rem; overflow-wrap: anywhere; }
.rich-editor:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(79,124,255,.12); }
.rich-editor:empty::before { content: attr(data-placeholder); color: #98a3b4; pointer-events: none; }
.rich-editor img { max-width: 100%; height: auto; border-radius: 16px; display: block; margin: 15px auto; }
.rich-editor .sticker { display: inline-block; font-size: 4rem; line-height: 1; }
.upload-status { padding: 9px 12px; background: #e8f3ff; color: #1f599a; border-inline: 1px solid var(--line); font-weight: 800; }
.editor-options { position: sticky; top: 96px; display: grid; gap: 22px; }
.mood-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 7px; }
.mood-grid span { display: grid; place-items: center; min-height: 48px; border: 2px solid var(--line); border-radius: 12px; background: var(--surface-strong); font-size: 1.5rem; cursor: pointer; }
.mood-grid input:checked + span { border-color: var(--primary); transform: scale(1.06); box-shadow: 0 0 0 3px rgba(79,124,255,.12); }
.post-theme-picker { display: grid; grid-template-columns: repeat(2,1fr); gap: 8px; }
.post-theme-dot span { display: grid; place-items: center; min-height: 46px; border: 3px solid transparent; border-radius: 12px; color: #26344d; text-transform: capitalize; cursor: pointer; font-size: .86rem; font-weight: 900; }
.post-theme-dot input:checked + span { border-color: #2d4f94; box-shadow: 0 0 0 2px #fff; }
.editor-tip { display: grid; gap: 7px; padding: 14px; border-radius: 16px; background: rgba(255,229,116,.28); }
.editor-tip button { text-align: left; border: 0; border-radius: 10px; padding: 9px; background: rgba(255,255,255,.78); color: #34425a; cursor: pointer; }
.editor-tip button:hover { background: #fff; }
.publish-button { width: 100%; }

.empty-state { min-height: 58vh; display: grid; place-items: center; align-content: center; text-align: center; gap: 10px; }
.empty-state h1, .empty-state h2 { margin: 0; }
.empty-state p { color: var(--muted); max-width: 500px; }
.empty-emoji { font-size: 5rem; }
.compact-empty { min-height: 380px; padding: 30px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }

@media (max-width: 880px) {
  .nav-toggle { display: block; }
  .main-nav { display: none; position: absolute; top: calc(100% + 6px); right: 12px; width: min(290px, calc(100vw - 24px)); padding: 10px; flex-direction: column; align-items: stretch; background: var(--surface-strong); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); }
  .main-nav.open { display: flex; }
  .main-nav a, .nav-link-button { display: block; width: 100%; text-align: left; }
  .feature-grid, .feature-grid.admin-grid, .post-grid, .game-admin-list { grid-template-columns: 1fr; }
  .two-column-layout, .settings-layout, .editor-layout { grid-template-columns: 1fr; }
  .sticky-card, .preview-stage, .editor-options { position: static; }
  .preview-stage { min-height: 430px; }
  .editor-options { order: -1; }
}

@media (max-width: 620px) {
  .page-shell { width: min(100% - 20px, 1180px); padding-top: 24px; }
  .topbar { min-height: 62px; padding: 8px 13px; }
  .hero-panel, .page-title-row, .game-header { align-items: flex-start; flex-direction: column; }
  .hero-emoji, .page-title-emoji { align-self: flex-end; margin-top: -35px; }
  .feature-card { min-height: 220px; padding: 24px; }
  .choice-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .game-header .button { align-self: stretch; width: 100%; }
  .ttt-board { gap: 7px; padding: 10px; border-radius: 20px; }
  .ttt-cell { border-radius: 13px; }
  .connect-board { gap: 4px; padding: 9px; border-radius: 20px; }
  .connect-cell { padding: 4px; }
  .reading-page { padding: 22px 17px 40px; }
  .reading-topbar { align-items: flex-start; flex-direction: column; }
  .post-meta { flex-direction: column; gap: 3px; }
  .editor-toolbar { max-height: 180px; overflow-y: auto; }
  .rich-editor { min-height: 370px; padding: 16px; }
  .inline-form { flex-direction: column; }
}

/* Secret Path */
.path-controls { width: min(760px, 100%); display: grid; gap: 12px; padding: 18px 22px; }
.path-controls > label { text-align: center; font-size: 1.05rem; }
.path-size-buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 9px; }
.path-size-buttons .button { min-width: 76px; }
.path-game-wrap { width: min(700px, 100%); display: grid; gap: 9px; }
.path-line { text-align: center; padding: 7px 14px; border-radius: 14px; font-weight: 900; letter-spacing: .08em; }
.path-finish-line { background: repeating-linear-gradient(45deg, #17243b 0 12px, #fff 12px 24px); color: #fff; text-shadow: 0 2px 4px #000; border: 3px solid #17243b; }
.path-start-line { background: #dff8e5; color: #176337; border: 3px solid #49ae6c; }
.path-board { --path-size: 5; display: grid; grid-template-columns: repeat(var(--path-size), 1fr); gap: clamp(3px, .7vw, 7px); padding: clamp(8px, 1.8vw, 16px); border-radius: 25px; background: #263c5f; box-shadow: var(--shadow); }
.path-tile { position: relative; aspect-ratio: 1; min-width: 0; border: 0; border-radius: clamp(6px, 1.2vw, 13px); background: #d8e1ed; box-shadow: inset 0 -4px 0 rgba(35,55,80,.17); cursor: pointer; display: grid; place-items: center; transition: transform .12s ease, background .16s ease; }
.path-tile:hover { transform: translateY(-2px); background: #edf3fa; }
.path-tile.safe { background: #55c878; box-shadow: inset 0 -4px 0 rgba(18,100,48,.25), 0 0 0 2px rgba(255,255,255,.7); }
.path-tile.wrong { background: #ef4f61; animation: pathWrong .18s linear 4 alternate; }
.path-tile.finish { background: #ffd84c; animation: winnerPulse .6s ease infinite alternate; }
.path-person { font-size: clamp(1.05rem, calc(4.8rem / var(--path-size) * 5), 3rem); line-height: 1; filter: drop-shadow(0 2px 1px rgba(0,0,0,.3)); transform: translateY(-4%); }
.path-help { max-width: 700px; margin: 0; color: var(--muted); text-align: center; font-weight: 800; }
@keyframes pathWrong { to { transform: translateX(5px); } }

@media (max-width: 620px) {
  .path-controls { padding: 15px; }
  .path-size-buttons .button { min-width: 67px; padding-inline: 10px; }
  .path-board { border-radius: 18px; }
}

/* Multiplayer Rooms */
.rooms-card { background-image: linear-gradient(145deg, var(--surface), rgba(126, 226, 160, .24)); }
.multiplayer-banner { display: flex; align-items: center; gap: 17px; margin: 0 0 24px; padding: 20px 24px; color: var(--ink); text-decoration: none; background: linear-gradient(135deg, rgba(84, 205, 125, .2), var(--surface)); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); }
.multiplayer-banner-icon { font-size: 2.8rem; }
.multiplayer-banner span { display: grid; flex: 1; }
.multiplayer-banner strong { font-size: 1.25rem; }
.multiplayer-banner small { color: var(--muted); font-weight: 700; }
.multiplayer-banner b { color: var(--primary); white-space: nowrap; }

.rooms-layout { display: grid; grid-template-columns: minmax(280px, .55fr) minmax(0, 1.2fr); gap: 26px; align-items: start; }
.room-create-card { position: sticky; top: 94px; }
.secret-room-options { display: grid; gap: 18px; padding: 17px; border-radius: 17px; background: rgba(79, 124, 255, .08); border: 1px solid var(--line); }
.secret-room-options[hidden] { display: none; }
.room-list-heading { display: flex; justify-content: space-between; align-items: end; gap: 16px; margin-bottom: 15px; }
.room-list-heading h2 { margin: 0; }
.room-list-heading p { margin: 3px 0 0; color: var(--muted); }
.live-pill { display: inline-flex; align-items: center; gap: 7px; padding: 6px 11px; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; font-weight: 900; font-size: .82rem; }
.live-pill span, .room-connection span { width: 9px; height: 9px; border-radius: 50%; background: #49bd72; box-shadow: 0 0 0 4px rgba(73, 189, 114, .15); }
.room-list { display: grid; gap: 15px; }
.room-list-card { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 20px 22px; }
.room-list-main { display: flex; align-items: center; gap: 17px; min-width: 0; }
.room-list-main > div:last-child { min-width: 0; }
.room-game-icon { width: 72px; height: 72px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 20px; background: rgba(79, 124, 255, .1); font-size: 2rem; }
.room-title-line { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; }
.room-title-line h3 { margin: 0; font-size: 1.3rem; overflow-wrap: anywhere; }
.room-list-card p { margin: 3px 0 0; color: var(--muted); font-size: .92rem; }
.room-list-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.room-list-actions form { margin: 0; }
.room-status { padding: 4px 9px; border-radius: 999px; text-transform: capitalize; font-weight: 900; font-size: .75rem; }
.room-status-waiting { background: #fff0b8; color: #755300; }
.room-status-playing { background: #d7f7e2; color: #146237; }
.room-status-finished { background: #e3e9ff; color: #304f9e; }
.room-empty { display: grid; justify-items: center; text-align: center; min-height: 260px; align-content: center; }
.room-empty span { font-size: 4rem; }
.room-empty h3 { margin: 8px 0 0; }
.room-empty p { margin: 3px 0 0; color: var(--muted); }

.room-page { display: grid; gap: 20px; }
.room-game-header h1 { margin-bottom: 4px; }
.room-header-actions { justify-content: flex-end; }
.room-connection { justify-self: start; display: inline-flex; align-items: center; gap: 6px; padding: 7px 12px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-size: .82rem; font-weight: 900; }
.room-connection.disconnected span { background: #dc5266; box-shadow: 0 0 0 4px rgba(220, 82, 102, .14); }
.room-alert { position: fixed; z-index: 80; top: 82px; left: 50%; transform: translateX(-50%); width: min(520px, calc(100vw - 28px)); padding: 13px 18px; border-radius: 15px; box-shadow: 0 14px 40px rgba(0,0,0,.2); font-weight: 900; text-align: center; }
.room-alert-error { background: #ffe5ea; color: #8e2035; border: 1px solid #ffbac8; }
.room-alert-success { background: #def7e7; color: #17613a; border: 1px solid #a9dfbd; }
.room-play-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 24px; align-items: start; }
.room-game-stage { min-width: 0; display: grid; justify-items: center; gap: 21px; }
.room-game-status { text-align: center; }
.room-waiting-panel { width: min(650px, 100%); text-align: center; display: grid; justify-items: center; }
.room-waiting-icon { font-size: 4rem; }
.room-waiting-panel h2 { margin: 4px 0; }
.room-waiting-panel p { color: var(--muted); }
.room-host-note { margin-bottom: 0; font-size: .9rem; }
.multiplayer-board-panel { width: 100%; display: grid; justify-items: center; }
.multiplayer-board-panel[hidden] { display: none; }
.multiplayer-ttt-board .ttt-cell:disabled { cursor: default; }
.connect-drop-buttons button:disabled { opacity: .25; cursor: default; }
.room-round-actions { display: grid; justify-items: center; }
.room-members-card { position: sticky; top: 94px; padding: 20px; }
.room-members-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.room-members-heading h2 { margin: 0; }
.room-members-heading span { color: var(--muted); font-size: .82rem; font-weight: 900; }
.room-member-list { display: grid; gap: 9px; margin: 17px 0; }
.room-member { display: grid; grid-template-columns: 44px 1fr 12px; align-items: center; gap: 10px; padding: 9px; border-radius: 14px; background: rgba(79, 124, 255, .06); }
.room-member.is-you { box-shadow: inset 0 0 0 2px rgba(79, 124, 255, .35); }
.room-member-marker { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; background: var(--surface-strong); font-size: 1.45rem; font-weight: 900; }
.room-member > div { display: grid; min-width: 0; }
.room-member strong { overflow: hidden; text-overflow: ellipsis; }
.room-member > div span { color: var(--muted); font-size: .78rem; }
.online-dot { width: 9px; height: 9px; border-radius: 50%; background: #aab2c1; }
.online-dot.online { background: #49bd72; box-shadow: 0 0 0 3px rgba(73, 189, 114, .15); }
.room-share-box { display: grid; justify-items: center; gap: 6px; padding: 14px; border-radius: 15px; background: rgba(255, 214, 47, .15); border: 1px dashed rgba(117, 83, 0, .3); }
.room-share-box > span { color: var(--muted); font-size: .78rem; font-weight: 900; text-transform: uppercase; letter-spacing: .1em; }
.room-share-box strong { font-size: 1.65rem; letter-spacing: .16em; }

.multiplayer-path-panel { gap: 14px; }
.path-scoreboard { width: min(760px, 100%); display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: 8px; }
.path-player-score { display: flex; align-items: center; gap: 9px; padding: 9px 11px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
.path-player-score.current-turn { box-shadow: 0 0 0 3px rgba(79, 124, 255, .22); }
.path-player-score > span { font-size: 1.55rem; }
.path-player-score > div { display: grid; min-width: 0; }
.path-player-score strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.path-player-score small { color: var(--muted); }
.multiplayer-path-board .path-tile:disabled { cursor: default; }
.multiplayer-path-board .path-tile:disabled:hover { transform: none; }
.multiplayer-person { display: inline-block; margin: -3px; font-size: clamp(.9rem, calc(4rem / var(--path-size) * 5), 2.6rem); }
.multiplayer-person.is-you { position: relative; z-index: 2; filter: drop-shadow(0 0 3px #fff) drop-shadow(0 2px 1px rgba(0,0,0,.35)); transform: scale(1.13); }

.room-chat-toggle { position: fixed; z-index: 70; right: max(18px, env(safe-area-inset-right)); bottom: max(18px, env(safe-area-inset-bottom)); width: 62px; height: 62px; border: 0; border-radius: 50%; background: var(--primary); color: #fff; box-shadow: 0 13px 35px rgba(35, 69, 150, .35); font-size: 1.75rem; cursor: pointer; }
.chat-new-badge { position: absolute; top: -6px; right: -9px; padding: 4px 8px; border-radius: 999px; background: #ef4f61; color: #fff; font-size: .68rem; font-weight: 900; border: 3px solid #fff; }
.room-chat-drawer { position: fixed; z-index: 91; top: 0; right: 0; width: min(410px, 94vw); height: 100dvh; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; background: var(--surface-strong); color: var(--ink); box-shadow: -18px 0 55px rgba(0,0,0,.22); transform: translateX(105%); transition: transform .22s ease; }
.room-chat-drawer.open { transform: translateX(0); }
.chat-drawer-header { display: flex; justify-content: space-between; align-items: center; gap: 15px; padding: 18px 19px; border-bottom: 1px solid var(--line); }
.chat-drawer-header h2 { margin: 0; font-size: 1.25rem; }
.chat-drawer-header button { width: 42px; height: 42px; border: 0; border-radius: 50%; background: rgba(79,124,255,.1); color: var(--ink); font-size: 1.8rem; cursor: pointer; }
.chat-messages { min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; padding: 17px; background: rgba(79,124,255,.04); }
.chat-message { align-self: flex-start; max-width: 88%; padding: 10px 12px; border-radius: 15px 15px 15px 4px; background: var(--surface-strong); border: 1px solid var(--line); box-shadow: 0 5px 14px rgba(0,0,0,.06); }
.chat-message.mine { align-self: flex-end; border-radius: 15px 15px 4px 15px; background: #dfe9ff; color: #213454; }
.chat-message > div { display: flex; justify-content: space-between; gap: 14px; font-size: .74rem; }
.chat-message time { color: var(--muted); }
.chat-message p { margin: 4px 0 0; overflow-wrap: anywhere; }
.chat-compose { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; padding: 13px; border-top: 1px solid var(--line); padding-bottom: max(13px, env(safe-area-inset-bottom)); }
.chat-compose input { min-width: 0; }
.chat-backdrop { position: fixed; z-index: 90; inset: 0; background: rgba(10, 20, 40, .38); }

@media (min-width: 1050px) {
  body.room-chat-docked .page-shell {
    width: min(1180px, calc(100vw - 442px));
    margin-left: calc((100vw - 410px - min(1180px, calc(100vw - 442px))) / 2);
    margin-right: 0;
    transition: width .22s ease, margin .22s ease;
  }
  .room-chat-drawer.desktop-docked { top: 72px; z-index: 19; width: 410px; height: calc(100dvh - 72px); }
  .room-page.chat-docked .room-play-layout { grid-template-columns: 1fr; }
  .room-page.chat-docked .room-members-card { position: static; width: min(700px, 100%); justify-self: center; }
  .room-page.chat-docked .chat-backdrop { display: none; }
}

@media (max-width: 930px) {
  .rooms-layout, .room-play-layout { grid-template-columns: 1fr; }
  .room-create-card, .room-members-card { position: static; }
  .room-members-card { width: min(700px, 100%); justify-self: center; }
}

@media (max-width: 620px) {
  .multiplayer-banner { align-items: flex-start; padding: 17px; }
  .multiplayer-banner b { display: none; }
  .room-list-card { align-items: stretch; flex-direction: column; }
  .room-list-main { align-items: flex-start; }
  .room-game-icon { width: 58px; height: 58px; border-radius: 16px; font-size: 1.55rem; }
  .room-list-actions { justify-content: stretch; }
  .room-list-actions > * { flex: 1; }
  .room-list-actions .button { width: 100%; }
  .room-header-actions { width: 100%; }
  .room-header-actions form { flex: 1; }
  .room-header-actions .button { width: 100%; }
  .room-play-layout { gap: 18px; }
  .path-scoreboard { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .path-player-score { padding: 7px; }
  .path-player-score > span { font-size: 1.25rem; }
  .path-player-score small { font-size: .68rem; }
  .room-chat-toggle { width: 56px; height: 56px; }
  .room-chat-drawer { width: 100vw; }
}

/* Treasure Trail */
.treasure-page { display: grid; gap: 20px; }
.treasure-controls { width: min(900px, 100%); justify-self: center; display: grid; grid-template-columns: minmax(170px, .55fr) minmax(260px, 1.4fr) auto; align-items: end; gap: 16px; padding: 18px 22px; }
.treasure-turn-card { min-height: 70px; display: flex; align-items: center; gap: 12px; padding: 10px 15px; border-radius: 18px; background: rgba(79,124,255,.08); border: 1px solid var(--line); }
.treasure-turn-card > span { font-size: 2.2rem; }
.treasure-turn-card > div { display: grid; min-width: 0; }
.treasure-turn-card strong { font-size: 1.05rem; }
.treasure-turn-card small { color: var(--muted); overflow-wrap: anywhere; }
.treasure-roll-button { min-width: 150px; min-height: 70px; display: inline-flex; align-items: center; justify-content: center; gap: 10px; padding: 11px 18px; border: 0; border-radius: 19px; background: linear-gradient(145deg, #ffcf3f, #ff9f2f); color: #4c2b00; box-shadow: 0 8px 0 #d97919, 0 15px 28px rgba(140,78,10,.22); cursor: pointer; font-weight: 900; transition: transform .12s ease, box-shadow .12s ease; }
.treasure-roll-button:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 10px 0 #d97919, 0 18px 30px rgba(140,78,10,.24); }
.treasure-roll-button:active:not(:disabled) { transform: translateY(5px); box-shadow: 0 3px 0 #d97919, 0 8px 18px rgba(140,78,10,.2); }
.treasure-roll-button:disabled { opacity: .45; cursor: default; box-shadow: 0 5px 0 #b98b52; }
.treasure-die { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 11px; background: #fff; color: #253451; border: 2px solid rgba(76,43,0,.18); font-size: 1.7rem; line-height: 1; }
.treasure-scoreboard { width: min(900px, 100%); justify-self: center; display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 9px; }
.treasure-player-card { display: flex; align-items: center; gap: 10px; min-width: 0; padding: 10px 12px; border-radius: 16px; background: var(--surface); border: 2px solid var(--line); box-shadow: 0 7px 18px rgba(33,62,105,.08); }
.treasure-player-card.current-turn { border-color: #ffb52d; box-shadow: 0 0 0 4px rgba(255,181,45,.2), 0 7px 18px rgba(33,62,105,.08); }
.treasure-player-card > span { font-size: 1.7rem; }
.treasure-player-card > div { display: grid; min-width: 0; }
.treasure-player-card strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.treasure-player-card small { color: var(--muted); }
.treasure-board { position: relative; width: min(820px, 100%); aspect-ratio: 1; justify-self: center; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-template-rows: repeat(7, minmax(0, 1fr)); gap: clamp(5px, 1vw, 10px); padding: clamp(10px, 2vw, 20px); border: clamp(6px, 1vw, 10px) solid #7c4a23; border-radius: 28px; background-color: #8fd36f; background-image: radial-gradient(circle at 20% 25%, rgba(255,255,255,.22) 0 2px, transparent 3px), radial-gradient(circle at 70% 75%, rgba(35,112,50,.16) 0 3px, transparent 4px); background-size: 42px 42px, 58px 58px; box-shadow: inset 0 0 0 4px rgba(255,255,255,.2), var(--shadow); }
.treasure-space { position: relative; min-width: 0; min-height: 0; display: grid; place-items: center; border: 2px solid rgba(50,65,88,.16); border-radius: clamp(10px, 1.7vw, 18px); background: #fff8da; color: #27364f; box-shadow: inset 0 -5px 0 rgba(89,67,16,.13), 0 4px 8px rgba(45,76,41,.12); overflow: visible; }
.treasure-space:nth-child(3n) { background: #e5f5ff; }
.treasure-space:nth-child(3n + 1) { background: #ffe9f1; }
.treasure-space.start { background: #d9f8df; border-color: #3fa965; }
.treasure-space.finish { background: #ffe45c; border-color: #9d6a00; animation: winnerPulse .8s ease infinite alternate; }
.treasure-space.mystery { background: #eee3ff; border-color: #8a66d5; }
.treasure-space.forward { background: #d7f7ff; border-color: #36a7c5; }
.treasure-space.backward { background: #dcecff; border-color: #5a86c8; }
.treasure-space.again { background: #fff4bc; border-color: #dcae1e; }
.treasure-space-number { position: absolute; top: 5px; left: 7px; font-size: clamp(.52rem, 1.25vw, .76rem); font-weight: 900; line-height: 1; opacity: .72; }
.treasure-space-icon { font-size: clamp(.9rem, 3vw, 2rem); line-height: 1; transform: translateY(-4%); }
.treasure-tokens { position: absolute; z-index: 2; right: 3px; bottom: 2px; left: 3px; display: flex; align-items: end; justify-content: center; flex-wrap: wrap; gap: 0; pointer-events: none; }
.treasure-token { display: inline-block; margin: -5px; font-size: clamp(1.05rem, 3.2vw, 2.15rem); line-height: 1; filter: drop-shadow(0 2px 1px rgba(0,0,0,.28)); }
.treasure-legend { width: min(820px, 100%); justify-self: center; display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.treasure-legend span { padding: 6px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-size: .78rem; font-weight: 900; }
.treasure-choice-backdrop { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: 18px; background: rgba(16,28,52,.55); backdrop-filter: blur(4px); }
.treasure-choice-card { width: min(610px, 100%); padding: clamp(24px, 5vw, 42px); text-align: center; border-radius: 30px; background: var(--surface-strong); color: var(--ink); border: 1px solid var(--line); box-shadow: 0 25px 80px rgba(0,0,0,.32); }
.treasure-choice-icon { font-size: 3.8rem; }
.treasure-choice-card h2 { margin: 3px 0 5px; font-size: clamp(1.7rem, 5vw, 2.5rem); }
.treasure-choice-card p { margin: 0 auto 22px; max-width: 480px; color: var(--muted); }
.treasure-box-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 13px; }
.treasure-box { min-width: 0; min-height: 145px; display: grid; place-items: center; align-content: center; gap: 5px; padding: 14px 8px; border: 3px solid #9a6ce0; border-radius: 22px; background: linear-gradient(145deg, #f8eaff, #dfcaff); color: #43236f; box-shadow: inset 0 -7px 0 rgba(91,53,145,.16), 0 9px 20px rgba(70,42,110,.17); cursor: pointer; transition: transform .15s ease; }
.treasure-box:hover:not(:disabled) { transform: translateY(-5px) rotate(-1deg); }
.treasure-box:nth-child(2):hover:not(:disabled) { transform: translateY(-5px) rotate(1deg); }
.treasure-box:disabled { opacity: .62; cursor: default; }
.treasure-box span { font-size: clamp(2.5rem, 8vw, 4rem); line-height: 1; }
.treasure-room-controls { width: min(820px, 100%); display: flex; align-items: center; justify-content: center; gap: 14px; }
.treasure-room-action { flex: 1; min-height: 70px; display: grid; place-items: center; padding: 12px 16px; text-align: center; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-weight: 900; }
.multiplayer-treasure-panel { width: 100%; gap: 14px; }

.treasure-moving-token { position: absolute; z-index: 20; margin: 0; transform: translate(-50%, -50%); font-size: clamp(1.25rem, 3.8vw, 2.55rem); pointer-events: none; transition: left .165s ease-in-out, top .165s ease-in-out; filter: drop-shadow(0 4px 3px rgba(0,0,0,.35)); will-change: left, top; }
.treasure-result-backdrop { z-index: 110; }
.treasure-result-card { width: min(460px, 100%); padding-block: clamp(30px, 7vw, 54px); }
.treasure-result-icon { font-size: clamp(4rem, 14vw, 6.5rem); line-height: 1; animation: treasurePrizePop .45s cubic-bezier(.2,.8,.2,1); }
.treasure-result-card h2 { margin: 10px 0 6px; }
.treasure-result-card p { margin-bottom: 0; font-size: clamp(1rem, 3.2vw, 1.3rem); font-weight: 900; }
@keyframes treasurePrizePop { from { transform: scale(.45) rotate(-10deg); opacity: 0; } to { transform: scale(1) rotate(0); opacity: 1; } }

@media (max-width: 720px) {
  .treasure-controls { grid-template-columns: 1fr 1fr; align-items: stretch; }
  .treasure-turn-card { grid-column: 1 / -1; order: -1; }
  .treasure-roll-button { min-width: 0; }
  .treasure-board { border-radius: 20px; }
  .treasure-room-controls { align-items: stretch; flex-direction: column; }
  .treasure-room-controls .treasure-roll-button { width: 100%; }
}

@media (max-width: 470px) {
  .treasure-controls { grid-template-columns: 1fr; }
  .treasure-turn-card { grid-column: auto; }
  .treasure-board { gap: 4px; padding: 7px; border-width: 5px; border-radius: 16px; }
  .treasure-space { border-width: 1px; border-radius: 8px; box-shadow: inset 0 -3px 0 rgba(89,67,16,.12); }
  .treasure-space-number { top: 3px; left: 4px; font-size: .44rem; }
  .treasure-space-icon { font-size: clamp(.72rem, 4.2vw, 1.35rem); }
  .treasure-token { margin: -4px; font-size: clamp(.98rem, 5vw, 1.55rem); }
  .treasure-moving-token { margin: 0; font-size: clamp(1.15rem, 6vw, 1.85rem); }
  .treasure-box-grid { gap: 7px; }
  .treasure-box { min-height: 115px; border-radius: 16px; }
  .treasure-box strong { font-size: .78rem; }
}

/* App-like PWA and compact game layouts */
html,
body {
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  overscroll-behavior-x: none;
}

html { touch-action: pan-y; }
button,
a,
input,
textarea,
select,
[role="button"] { touch-action: manipulation; }
img,
svg,
video,
canvas { max-width: 100%; }

@media (display-mode: standalone) {
  body { overscroll-behavior-y: none; }
}

.page-shell:has(.game-page),
.page-shell:has(.room-page) {
  padding-top: clamp(14px, 2.5vh, 26px);
  padding-bottom: 32px;
}

.game-page {
  width: 100%;
  min-width: 0;
  gap: clamp(10px, 1.8vh, 18px);
}

.game-header {
  align-items: center;
  gap: 14px;
}

.game-header > div { min-width: 0; }
.game-header h1 {
  margin: 2px 0 3px;
  font-size: clamp(1.9rem, 4.5vw, 3.1rem);
  line-height: 1.05;
}
.game-header p {
  max-width: 760px;
  font-size: .92rem;
  line-height: 1.35;
}

.game-status {
  position: sticky;
  top: 82px;
  z-index: 12;
  max-width: min(720px, 100%);
  padding: 9px 16px;
  text-align: center;
  font-size: 1rem;
  line-height: 1.25;
  backdrop-filter: blur(14px);
}

.ttt-board { width: min(520px, 100%, 62dvh); }
.connect-board-wrap { width: min(720px, 100%, 76dvh); }
.path-game-wrap { width: min(700px, 100%, 64dvh); }
.treasure-board { width: min(820px, 100%, 62dvh); }

.score-strip {
  width: min(520px, 100%, 62dvh);
  gap: 8px;
}
.score-strip div { padding: 9px 12px; }
.score-strip strong { font-size: 1.25rem; line-height: 1; }

.path-controls {
  gap: 8px;
  padding: 11px 14px;
}
.path-controls > label { font-size: .9rem; }
.path-size-buttons { gap: 6px; }
.path-size-buttons .button {
  min-width: 64px;
  padding: 8px 11px;
}
.path-help {
  font-size: .82rem;
  line-height: 1.35;
}

.treasure-page { gap: clamp(9px, 1.4vh, 14px); }
.treasure-controls {
  grid-template-columns: minmax(145px, .48fr) minmax(230px, 1.25fr) auto;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
}
.treasure-controls label {
  gap: 4px;
  font-size: .78rem;
}
.treasure-controls select { padding: 8px 10px; }
.treasure-turn-card {
  min-height: 58px;
  padding: 7px 11px;
}
.treasure-turn-card > span { font-size: 1.8rem; }
.treasure-turn-card strong { font-size: .95rem; }
.treasure-turn-card small {
  font-size: .76rem;
  line-height: 1.25;
}
.treasure-roll-button {
  min-width: 132px;
  min-height: 58px;
  padding: 8px 13px;
  border-radius: 17px;
}
.treasure-die {
  width: 38px;
  height: 38px;
  font-size: 1.45rem;
}
.treasure-scoreboard {
  width: min(820px, 100%, 62dvh);
  grid-template-columns: repeat(auto-fit, minmax(125px, 1fr));
  gap: 6px;
}
.treasure-player-card {
  gap: 7px;
  padding: 7px 9px;
  border-radius: 13px;
}
.treasure-player-card > span { font-size: 1.4rem; }
.treasure-player-card strong { font-size: .84rem; }
.treasure-player-card small { font-size: .7rem; }
.treasure-legend { gap: 5px; }
.treasure-legend span {
  padding: 4px 8px;
  font-size: .68rem;
}

.room-page { gap: 12px; }
.room-game-header {
  align-items: center;
  gap: 12px;
}
.room-game-header h1 {
  margin: 2px 0;
  font-size: clamp(1.8rem, 4vw, 2.8rem);
}
.room-game-header p { margin: 0; }
.room-connection { padding: 5px 10px; }
.room-play-layout { gap: 18px; }
.room-game-stage {
  min-width: 0;
  gap: 10px;
}
.room-game-status {
  width: min(720px, 100%);
  margin-inline: auto;
}
.room-board-area {
  position: relative;
  isolation: isolate;
  width: 100%;
  min-width: 0;
  min-height: min(520px, calc(100vw - 28px));
  display: grid;
  justify-items: center;
}
.room-board-area > .multiplayer-board-panel { grid-area: 1 / 1; }
.multiplayer-board-panel { min-width: 0; }
.room-game-overlay {
  position: absolute;
  z-index: 30;
  inset: 0;
  width: 100%;
  min-height: 100%;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  padding: clamp(18px, 5vw, 38px);
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: linear-gradient(rgba(255,255,255,.76), rgba(255,255,255,.9));
  box-shadow: inset 0 0 55px rgba(46, 83, 145, .08);
  backdrop-filter: blur(4px);
}
.theme-space .room-game-overlay {
  background: linear-gradient(rgba(17,25,52,.72), rgba(17,25,52,.9));
}
.room-game-overlay[hidden] { display: none; }
.room-waiting-panel h2 { margin: 2px 0; }
.room-waiting-panel p {
  max-width: 520px;
  margin: 2px 0;
}
.room-waiting-icon { font-size: clamp(2.5rem, 8vw, 4rem); }
.room-host-note { margin-top: 4px !important; }
.room-round-actions {
  position: absolute;
  z-index: 35;
  left: 50%;
  bottom: clamp(10px, 3vw, 24px);
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 24px);
  padding: 7px;
  border-radius: 18px;
  background: rgba(255,255,255,.84);
  border: 1px solid var(--line);
  box-shadow: 0 14px 38px rgba(0,0,0,.22);
  backdrop-filter: blur(10px);
}
.theme-space .room-round-actions { background: rgba(17,25,52,.88); }
.room-round-actions[hidden] { display: none; }
.room-round-actions .button { white-space: nowrap; }

.multiplayer-ttt-board { width: min(520px, 100%, 62dvh); }
.multiplayer-path-panel { gap: 8px; }
.multiplayer-path-panel .path-game-wrap { width: min(700px, 100%, 58dvh); }
.path-scoreboard {
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 6px;
}
.path-player-score { padding: 6px 8px; }
.path-player-score > span { font-size: 1.3rem; }
.path-player-score strong { font-size: .8rem; }
.path-player-score small { font-size: .68rem; }
.multiplayer-treasure-panel { gap: 8px; }
.multiplayer-treasure-panel .treasure-board { width: min(820px, 100%, 56dvh); }
.multiplayer-treasure-panel .treasure-scoreboard { width: min(820px, 100%, 56dvh); }
.treasure-room-controls {
  width: min(820px, 100%, 72dvh);
  gap: 8px;
}
.treasure-room-action {
  min-height: 56px;
  padding: 8px 12px;
  font-size: .82rem;
  line-height: 1.3;
}
.treasure-room-controls .treasure-roll-button { min-height: 56px; }

@media (max-width: 720px) {
  .game-status { top: 69px; }

  .treasure-controls {
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: stretch;
  }
  .treasure-controls > label {
    grid-column: 1;
    grid-row: 1;
  }
  .treasure-controls .treasure-turn-card {
    grid-column: 1 / -1;
    grid-row: 2;
    order: initial;
  }
  .treasure-controls .treasure-roll-button {
    grid-column: 2;
    grid-row: 1;
    min-width: 118px;
  }
  .treasure-room-controls {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: stretch;
  }
  .treasure-room-controls .treasure-roll-button {
    width: auto;
    min-width: 116px;
  }
}

@media (max-width: 620px) {
  .page-shell:has(.game-page),
  .page-shell:has(.room-page) {
    width: calc(100% - 14px);
    padding-top: 10px;
    padding-bottom: 22px;
  }

  .game-header,
  .room-game-header {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }
  .game-header h1,
  .room-game-header h1 {
    font-size: clamp(1.45rem, 7vw, 1.9rem);
    overflow-wrap: anywhere;
  }
  .game-header p,
  .room-game-header [data-room-subtitle] { display: none; }
  .game-header .back-link { font-size: .72rem; }
  .game-header .button {
    width: auto;
    flex: 0 0 auto;
    align-self: center;
    padding: 8px 11px;
    font-size: .8rem;
  }
  .room-header-actions {
    width: auto;
    flex: 0 0 auto;
    gap: 5px;
  }
  .room-header-actions form { flex: 0 0 auto; }
  .room-header-actions .button {
    width: auto;
    padding: 7px 9px;
    font-size: .72rem;
  }
  .room-game-header .eyebrow { font-size: .64rem; }
  .room-connection { font-size: .7rem; }

  .ttt-board,
  .multiplayer-ttt-board {
    gap: 6px;
    padding: 8px;
    border-radius: 18px;
  }
  .connect-drop-buttons { padding: 0 8px 4px; }
  .connect-board { padding: 7px; }
  .path-line {
    padding: 4px 9px;
    font-size: .72rem;
  }
  .path-game-wrap { gap: 5px; }
  .path-help { display: none; }
  .path-controls {
    gap: 6px;
    padding: 8px;
  }
  .path-controls > label { display: none; }
  .path-size-buttons { flex-wrap: nowrap; }
  .path-size-buttons .button {
    min-width: 0;
    flex: 1;
    padding: 7px 4px;
    font-size: .72rem;
  }

  .treasure-board,
  .multiplayer-treasure-panel .treasure-board {
    width: min(100%, 58dvh);
  }
  .treasure-scoreboard,
  .multiplayer-treasure-panel .treasure-scoreboard {
    width: min(100%, 58dvh);
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .treasure-player-card { padding: 5px 7px; }
  .treasure-controls { padding: 7px; }
  .treasure-turn-card { min-height: 50px; }
  .treasure-roll-button { min-height: 50px; }
  .treasure-die {
    width: 33px;
    height: 33px;
    font-size: 1.25rem;
  }
  .treasure-legend { display: none; }
  .treasure-room-action { min-height: 50px; }

  .room-play-layout { gap: 12px; }
  .room-game-stage { gap: 7px; }
  .room-game-overlay {
    padding: 15px;
    border-radius: 20px;
  }
  .room-waiting-panel p { font-size: .78rem; }
  .room-host-note { font-size: .72rem; }
  .room-round-actions {
    bottom: 8px;
    padding: 5px;
  }
  .room-round-actions .button {
    padding: 10px 14px;
    font-size: .86rem;
  }
  .room-members-card { padding: 14px; }
}

@media (min-width: 621px) and (max-height: 820px) {
  .page-shell:has(.game-page),
  .page-shell:has(.room-page) { padding-top: 12px; }
  .game-header p,
  .room-game-header [data-room-subtitle] { display: none; }
  .game-header h1,
  .room-game-header h1 { font-size: 2rem; }
  .ttt-board,
  .multiplayer-ttt-board { width: min(520px, 56dvh); }
  .path-game-wrap { width: min(700px, 56dvh); }
  .treasure-board { width: min(820px, 53dvh); }
  .multiplayer-treasure-panel .treasure-board { width: min(820px, 49dvh); }
  .multiplayer-treasure-panel .treasure-scoreboard { width: min(820px, 49dvh); }
}
