:root {
  --ink: #17252a;
  --muted: #607277;
  --paper: #f7f5ef;
  --card: #fffdf8;
  --lime: #c9f27c;
  --lime-dark: #7cad32;
  --coral: #ff765f;
  --blue: #4e8fda;
  --line: #d9ddd5;
  --shadow: 0 18px 50px rgba(23, 37, 42, .1);
}
* { box-sizing: border-box; }
html { color: var(--ink); background: var(--paper); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 85% 5%, #e4f7bd 0, transparent 26rem), var(--paper); }
button, input { font: inherit; }
a { color: inherit; }
.shell { width: min(1160px, calc(100% - 32px)); margin: 0 auto; }
.topbar { min-height: 76px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { font-weight: 900; font-size: 1.35rem; letter-spacing: -.055em; text-decoration: none; }
.brand-dot { color: var(--coral); }
.eyebrow { color: var(--muted); text-transform: uppercase; font-size: .7rem; font-weight: 800; letter-spacing: .14em; }
.pill, .button { min-height: 44px; border: 1px solid var(--ink); border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; padding: 0 18px; font-weight: 800; text-decoration: none; cursor: pointer; background: var(--ink); color: white; transition: transform .15s, box-shadow .15s; }
.button:hover, .pill:hover { transform: translateY(-1px); box-shadow: 0 7px 0 rgba(23,37,42,.12); }
.button.secondary { color: var(--ink); background: transparent; border-color: var(--line); }
.button.coral { background: var(--coral); border-color: var(--coral); }
input { width: 100%; min-height: 50px; border: 1px solid var(--line); border-radius: 13px; padding: 0 15px; color: var(--ink); background: white; outline: none; }
input:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(78,143,218,.14); }
label { display: block; font-size: .78rem; font-weight: 800; margin: 0 0 7px; }
.card { border: 1px solid var(--line); background: rgba(255,253,248,.92); border-radius: 24px; box-shadow: var(--shadow); }
.muted { color: var(--muted); }
.home { min-height: calc(100vh - 76px); display: grid; grid-template-columns: 1.08fr .92fr; gap: clamp(35px, 7vw, 90px); align-items: center; padding: 45px 0 110px; }
.home h1 { font-family: Georgia, serif; font-size: clamp(3.8rem, 8vw, 7.4rem); line-height: .84; letter-spacing: -.075em; margin: 15px 0 30px; font-weight: 500; }
.home h1 em { font-style: normal; color: var(--coral); }
.home-copy { max-width: 590px; font-size: clamp(1.05rem, 2vw, 1.3rem); line-height: 1.6; }
.join-card { padding: clamp(24px, 5vw, 48px); position: relative; overflow: hidden; }
.join-card::before { content: ""; position: absolute; width: 150px; height: 150px; border: 32px solid var(--lime); border-radius: 50%; right: -72px; top: -72px; }
.join-card h2 { font-family: Georgia, serif; font-size: 2rem; margin: 5px 0 25px; }
.join-form { display: grid; gap: 17px; }
.code-input { text-transform: uppercase; letter-spacing: .22em; font-weight: 900; }
.join-form .button { width: 100%; margin-top: 5px; }
.demo-link { display: block; text-align: center; margin-top: 18px; font-size: .86rem; color: var(--muted); }

/* Game */
.game-header { display: flex; align-items: end; justify-content: space-between; padding: 14px 0 18px; gap: 20px; }
.game-header h1 { font-family: Georgia, serif; font-size: clamp(1.55rem, 4vw, 2.4rem); margin: 4px 0 0; font-weight: 500; }
.game-list-layout { width: min(760px, calc(100% - 32px)); display: grid; gap: 22px; padding-bottom: 60px; }
.game-list-layout .guess-panel { position: static; padding: clamp(20px, 4vw, 32px); }
.game-list-layout .guess-panel h2 { font-size: clamp(1.7rem, 4vw, 2.25rem); }
.game-list-layout .guess-form { margin-top: 22px; }
.game-list-layout .guess-list-card { grid-column: auto; }
.game-list-layout .guess-list { max-height: min(58vh, 620px); }
.latest-card { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: clamp(20px, 4vw, 28px); border-color: rgba(124,173,50,.45); background: linear-gradient(135deg, rgba(201,242,124,.3), rgba(255,253,248,.96)); }
.latest-card[hidden] { display: none; }
.latest-word { display: block; margin-top: 4px; font-family: Georgia, serif; font-size: clamp(1.7rem, 5vw, 2.5rem); font-weight: 500; }
.latest-score { flex: 0 0 auto; padding: 10px 15px; border-radius: 999px; background: var(--ink); color: white; font-size: clamp(.82rem, 2.2vw, 1rem); font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.guess-panel { padding: 22px; position: sticky; top: 14px; }
.guess-panel h2 { font-family: Georgia, serif; font-size: 1.55rem; margin: 0 0 8px; font-weight: 500; }
.guess-form { display: flex; gap: 8px; margin: 18px 0 12px; }
.guess-form input { min-width: 0; }
.guess-form button { padding-inline: 16px; }
.status { min-height: 38px; font-size: .83rem; line-height: 1.45; color: var(--muted); }
.status.error { color: #b52e21; }
.status.success { color: #4d7d19; font-weight: 800; }
.loading-bar { height: 5px; border-radius: 5px; overflow: hidden; background: #e5e7e1; margin: 14px 0; }
.loading-bar span { display: block; height: 100%; width: 35%; background: var(--coral); animation: load 1s infinite alternate ease-in-out; }
@keyframes load { to { translate: 185% 0; } }
.guess-list-card { grid-column: 1 / -1; overflow: hidden; }
.section-head { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px; border-bottom: 1px solid var(--line); }
.section-head h2 { font-family: Georgia, serif; font-size: 1.55rem; font-weight: 500; margin: 0; }
.guess-list { max-height: 410px; overflow-y: auto; }
.guess-row, .leader-row { display: grid; grid-template-columns: 50px 1fr 155px; gap: 15px; align-items: center; padding: 13px 24px; border-bottom: 1px solid #ecece7; }
.guess-head { display: grid; grid-template-columns: 50px 1fr 155px; gap: 15px; padding: 10px 24px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: .68rem; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.guess-head span:last-child { text-align: right; }
.rank { color: var(--muted); font-variant-numeric: tabular-nums; }
.distance { text-align: right; font-variant-numeric: tabular-nums; font-weight: 800; white-space: nowrap; }
.empty { padding: 40px 24px; color: var(--muted); text-align: center; }

/* Admin */
.admin-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 28px; padding: 18px 0 60px; }
.sidebar { min-height: calc(100vh - 112px); padding: 20px; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.sidebar h2 { font-family: Georgia, serif; font-size: 1.4rem; font-weight: 500; margin: 0; }
.game-item { display: grid; grid-template-columns: minmax(0, 1fr) 38px; gap: 4px; align-items: center; margin-top: 8px; }
.game-link { display: block; min-width: 0; padding: 13px; border: 1px solid transparent; border-radius: 13px; text-decoration: none; }
.game-link:hover, .game-link.active { background: #f1f7e6; border-color: #dbe8c3; }
.game-link strong { display: block; letter-spacing: .12em; }
.game-link small { color: var(--muted); }
.trash-button { width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; color: var(--muted); background: transparent; cursor: pointer; font-size: 1.15rem; }
.trash-button:hover { color: #b52e21; background: rgba(181,46,33,.09); }
.archived { opacity: .55; }
.admin-main { min-width: 0; }
.admin-title { display: flex; align-items: start; justify-content: space-between; gap: 20px; margin: 0 0 24px; }
.admin-title h1 { font-family: Georgia, serif; font-size: clamp(2.2rem, 5vw, 4.6rem); letter-spacing: -.055em; line-height: .95; font-weight: 500; margin: 6px 0 0; }
.create-card { padding: clamp(22px, 4vw, 38px); }
.create-card h2 { font-family: Georgia, serif; font-size: 2rem; font-weight: 500; margin: 0 0 8px; }
.create-row { display: grid; grid-template-columns: 1fr auto auto; gap: 9px; margin-top: 22px; }
.preview { margin-top: 28px; border-top: 1px solid var(--line); padding-top: 22px; }
.preview-chips { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; max-height: 480px; margin-top: 14px; padding-right: 5px; overflow-y: auto; }
.chip { border-radius: 10px; background: #eef5e2; padding: 8px 11px; font-size: .82rem; font-weight: 700; }
.meta-card { padding: 22px; margin-bottom: 20px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.meta-card code { font-size: 2rem; font-weight: 900; letter-spacing: .15em; }
.leader-card { overflow: hidden; }
.leader-head, .leader-row { grid-template-columns: 45px minmax(100px, 1fr) 155px 100px; }
.leader-head { display: grid; gap: 15px; padding: 10px 24px; color: var(--muted); font-size: .7rem; font-weight: 900; text-transform: uppercase; letter-spacing: .08em; border-bottom: 1px solid var(--line); }
.word-cell.hidden-word { filter: blur(6px); user-select: none; }
.live { display: inline-flex; align-items: center; gap: 7px; font-size: .75rem; font-weight: 800; color: #568b21; }
.live::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #7fbf3e; box-shadow: 0 0 0 5px rgba(127,191,62,.13); }
.leader-stats { display: flex; flex-direction: column; align-items: flex-end; gap: 12px; }
.guess-total { font-size: 1rem; color: var(--muted); }
.guess-total strong { color: var(--ink); font-size: 1.4rem; font-variant-numeric: tabular-nums; }
.fireworks-canvas { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 9998; pointer-events: none; }
.winner-toast { position: fixed; z-index: 9999; left: 50%; top: 12%; translate: -50% 0; width: max-content; max-width: calc(100% - 32px); padding: 16px 24px; border: 2px solid var(--ink); border-radius: 999px; background: var(--lime); box-shadow: 0 12px 35px rgba(23,37,42,.25); font-family: Georgia, serif; font-size: clamp(1.25rem, 4vw, 2.2rem); font-weight: 700; text-align: center; animation: winner-in .35s ease-out; }
@keyframes winner-in { from { opacity: 0; transform: translateY(-20px) scale(.9); } }

@media (max-width: 800px) {
  .shell { width: min(100% - 22px, 680px); }
  .home { grid-template-columns: 1fr; padding: 35px 0 70px; }
  .home h1 { font-size: clamp(3.6rem, 20vw, 6.3rem); }
  .guess-panel { position: static; grid-row: 1; }
  .admin-layout { grid-template-columns: 1fr; }
  .sidebar { min-height: 0; }
  .sidebar-games { display: flex; overflow-x: auto; gap: 5px; }
  .game-item { min-width: 190px; }
}
@media (max-width: 520px) {
  .topbar { min-height: 62px; }
  .game-header { align-items: center; }
  .game-header .muted { display: none; }
  .guess-panel { padding: 18px; }
  .latest-card { align-items: flex-start; flex-direction: column; gap: 12px; }
  .guess-row { grid-template-columns: 35px 1fr 115px; padding: 12px 15px; }
  .guess-head { grid-template-columns: 35px 1fr 115px; padding: 9px 15px; }
  .create-row { grid-template-columns: 1fr 1fr; }
  .create-row input { grid-column: 1 / -1; }
  .preview-chips { grid-template-columns: 1fr; }
  .admin-title { flex-direction: column; }
  .leader-stats { align-items: flex-start; }
  .meta-card { align-items: start; flex-direction: column; }
  .leader-head, .leader-row { grid-template-columns: 30px minmax(70px, 1fr) 110px 62px; gap: 5px; padding-left: 10px; padding-right: 10px; font-size: .75rem; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; animation: none !important; transition: none !important; } }
