:root {
  --ink: #0b0d10;
  --paper: #f2f0ea;
  --muted: #a8aaa6;
  --acid: #c8f542;
  --line: rgba(242, 240, 234, 0.14);
  --bad: #e07050;
  --panel: #12151a;
  --board: #10141a;
  --font-display: "Bebas Neue", Impact, sans-serif;
  --font-body: "DM Sans", system-ui, sans-serif;
}

:root[data-theme="light"] {
  --ink: #f6f3ec;
  --paper: #1c1e18;
  --muted: #5e645c;
  --acid: #3f6a14;
  --line: rgba(28, 30, 24, 0.14);
  --bad: #b8432a;
  --panel: #fff;
  --board: #fff;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--ink);
  color: var(--paper);
  font-family: var(--font-body);
}
.top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 20;
}
.brand-block { display: flex; flex-direction: column; align-items: flex-start; gap: 0.2rem; min-width: 0; }
.mark { display: flex; align-items: center; gap: 0.75rem; text-decoration: none; color: var(--paper); }
.mark img { display: block; width: 44px; height: auto; }
.mark img.gamel-logo { width: 148px; height: auto; border-radius: 12px; }
.mark:has(.gamel-logo) span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
.mark span { font-family: var(--font-display); letter-spacing: 0.06em; font-size: 1.15rem; text-transform: none; }
.brand { margin: 0; color: var(--muted); font-size: 0.75rem; letter-spacing: 0.08em; text-transform: uppercase; }
h1 { margin: 0; font-family: var(--font-display); font-weight: 400; letter-spacing: 0.14em; font-size: 2.2rem; line-height: 0.9; }
h1.game-title { letter-spacing: 0.04em; font-size: clamp(1.35rem, 3.4vw, 1.85rem); line-height: 0.95; }
.who { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; justify-content: flex-end; }
.who a {
  text-decoration: none;
  background: var(--panel);
  color: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
}
.who a.account-go { background: var(--acid); color: var(--ink); border-color: var(--acid); }
.account-actions { display: flex; gap: 0.45rem; align-items: center; }
.account-actions a {
  text-decoration: none;
  background: var(--panel);
  color: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
}
.account-actions a.account-go {
  background: var(--acid);
  color: var(--ink);
  border-color: var(--acid);
}
.account-actions[hidden],
#login[hidden],
#google[hidden],
#logout[hidden],
#result-account[hidden],
#result-review[hidden],
#review-note[hidden] { display: none; }
.theme, .who button, .google, #username-form button, .account-buttons button {
  background: var(--panel);
  color: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.45rem 0.85rem;
  font: inherit;
  cursor: pointer;
}
.google { color: var(--acid); text-decoration: none; display: inline-block; margin-top: 0.6rem; }
.me { margin: 0; color: var(--muted); font-size: 0.9rem; }
.me:empty { display: none; }

main {
  width: min(40rem, calc(100% - 2rem));
  margin: 0 auto;
  padding: 2.5rem 0 3rem;
}
.panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 1.35rem;
}
.hud {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}
.date { margin: 0; color: var(--muted); font-size: 0.85rem; letter-spacing: 0.06em; }
.lives { margin: 0; font-family: var(--font-display); font-size: 2rem; letter-spacing: 0.28em; }
.lead { margin: 0.15rem 0 0; max-width: 22rem; color: var(--muted); font-size: 0.82rem; line-height: 1.45; }
.range-lead { margin: 0; max-width: 22rem; line-height: 1.4; }
.found { margin: 0; font: inherit; color: var(--paper); }
.hint-wait { margin: 0; color: var(--muted); font-size: 0.9rem; }
.modes { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; margin: 0; }
.modes button {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font: inherit;
  cursor: pointer;
}
.modes button.on { color: var(--ink); background: var(--acid); border-color: var(--acid); }
.year-range {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-end;
  gap: 0.55rem;
  margin: 0;
}
.year-range[hidden] { display: none; }
.year-range label {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.25rem;
  color: var(--muted);
  font-size: 0.78rem;
}
.year-range input {
  width: 5.6rem;
  background: transparent;
  color: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.4rem 0.7rem;
  font: inherit;
  text-align: center;
}
.year-range button {
  background: transparent;
  color: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.4rem 0.85rem;
  font: inherit;
  cursor: pointer;
}
.board {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: flex-end;
  gap: 0.85rem 1.6rem;
  min-height: 3.2rem;
  max-width: 36rem;
  width: 100%;
}
.word {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  justify-content: center;
  gap: 0.4rem;
  max-width: 100%;
}
.word.split {
  flex: 1 0 100%;
}
.slot {
  flex: 0 0 auto;
  min-width: 1.8rem;
  height: 2.6rem;
  border-bottom: 2px solid var(--line);
  text-align: center;
  font-family: var(--font-display);
  font-size: 1.9rem;
  line-height: 2.3rem;
}
.slot.mark { border: 0; min-width: 0.7rem; color: var(--muted); }
.slot.break {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  align-self: flex-end;
  min-width: 0.8rem;
  line-height: 1;
  font-size: 1.7rem;
  padding-bottom: 0.05rem;
  border: 0;
}
.slot.show { color: var(--acid); border-color: var(--acid); }
.status { margin: 0; line-height: 1.45; max-width: 28rem; }
.status:empty { display: none; }
.hint { margin: 0; color: var(--acid); white-space: pre-line; text-align: center; }
.hints {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 0.45rem 0.7rem;
  max-width: 36rem;
}
.hints-label { color: var(--muted); }
.hint-buttons { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.4rem; }
.actions { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 0.65rem; }
.hint-buttons button, #another, .keys button {
  background: var(--panel);
  color: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  cursor: pointer;
}
.hint-buttons button, #another { padding: 0.5rem 0.9rem; border-radius: 999px; }
.hint-buttons button:disabled, .hint-buttons button.is-locked { opacity: 0.4; }
.hint-buttons button.used { opacity: 0.7; }
.keys { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.4rem; max-width: 34rem; }
.keys button { width: 2.35rem; height: 2.7rem; }
.keys button.bad { color: var(--bad); border-color: var(--bad); }
.keys button.hit { color: var(--acid); border-color: var(--acid); }
.key-break { flex-basis: 100%; height: 0; }

.notes {
  margin-top: 3.5rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--line);
  text-align: center;
}
.notes h2 { margin: 0; font-family: var(--font-display); font-weight: 400; letter-spacing: 0.06em; font-size: 2rem; }
.howto {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  margin-top: 1.6rem;
}
.howto p {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.65rem, 4.5vw, 2.1rem);
  letter-spacing: 0.08em;
  line-height: 1;
  color: var(--paper);
}
.howto-mark {
  width: 3.15rem;
  height: 3.15rem;
  border-radius: 50%;
  border: 1.5px solid var(--line);
  background: transparent;
  color: var(--paper);
  font-family: var(--font-display);
  font-size: 2.05rem;
  line-height: 1;
  cursor: pointer;
}
.howto-mark:hover, .howto-mark:focus-visible { border-color: var(--acid); color: var(--acid); }
.tip { margin: 0.8rem auto 0; max-width: 26rem; color: var(--muted); line-height: 1.5; }
.note-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.6rem; margin-top: 1.1rem; }
.pill {
  display: inline-block;
  background: var(--acid);
  color: var(--ink);
  text-decoration: none;
  border-radius: 999px;
  padding: 0.55rem 1rem;
  font-weight: 500;
}
.pill.ghost { background: transparent; color: var(--paper); border: 1px solid var(--line); }
.fact {
  margin: 2.75rem auto 0;
  max-width: 24rem;
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.45;
}

dialog {
  position: relative;
  margin: auto;
  text-align: center;
  background: var(--panel);
  color: var(--paper);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.4rem 1.5rem;
  width: min(26rem, calc(100vw - 2rem));
}
.dialog-x {
  position: absolute;
  top: 0.45rem;
  right: 0.45rem;
  width: 1.7rem;
  height: 1.7rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}
.dialog-x:hover, .dialog-x:focus-visible { color: var(--paper); }
dialog.sheet {
  position: fixed;
  inset: auto 0 0 0;
  margin: 0 auto;
  width: min(34rem, 100%);
  max-width: 100%;
  max-height: min(88dvh, 100%);
  overflow: auto;
  border-radius: 18px 18px 0 0;
  border-bottom: 0;
  padding: 0.85rem 1.35rem calc(1.15rem + env(safe-area-inset-bottom));
  transform: translateY(100%);
}
dialog.sheet[open] { transform: translateY(0); }
dialog.sheet.sheet-out { transform: translateY(100%); }
dialog.sheet,
dialog.sheet::backdrop {
  transition: transform 0.32s ease, overlay 0.32s allow-discrete, display 0.32s allow-discrete;
}
@starting-style {
  dialog.sheet[open] { transform: translateY(100%); }
}
dialog.sheet::before {
  content: "";
  display: block;
  width: 2.5rem;
  height: 0.28rem;
  margin: 0.2rem auto 0.85rem;
  border-radius: 999px;
  background: var(--line);
}
@media (prefers-reduced-motion: reduce) {
  dialog.sheet, dialog.sheet::backdrop { transition: none; }
}
dialog::backdrop { background: rgba(0, 0, 0, 0.72); }
dialog ol { margin: 0.8rem 0 1rem; padding-left: 1.2rem; text-align: left; color: var(--muted); line-height: 1.5; }
dialog li + li { margin-top: 0.35rem; }
.result-label { margin: 0; letter-spacing: 0.14em; text-transform: uppercase; color: var(--acid); font-size: 0.75rem; }
#result-poster {
  display: block;
  margin: 0.2rem auto 0.7rem;
  max-height: 220px;
  width: auto;
  border-radius: 8px;
}
#result-poster[hidden] { display: none; }
dialog h2 { margin: 0.3rem 0 0.6rem; font-family: var(--font-display); font-weight: 400; letter-spacing: 0.04em; font-size: 2rem; }
#result-title a { color: inherit; }
#result-director, #result-cast, #result-rating {
  margin: 0.15rem 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}
#result-director strong, #result-cast strong { font-weight: 700; }
#result-director[hidden], #result-cast[hidden], #result-rating[hidden] { display: none; }
dialog p { color: var(--muted); line-height: 1.45; }
#login { display: flex; flex-direction: column; gap: 0.55rem; margin-top: 0.8rem; }
#login[hidden] { display: none; }
#login input, #username-form input {
  width: 100%;
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  font: inherit;
}
.account-buttons, #username-form { display: flex; justify-content: center; gap: 0.45rem; flex-wrap: wrap; }
#account-error:empty, #username-error:empty { display: none; }
#result-account { margin-top: 0.9rem; padding-top: 0.85rem; border-top: 1px solid var(--line); }
#result-account p { margin: 0 0 0.7rem; }
.result-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.5rem; }
.result-next { display: flex; flex-direction: column; align-items: center; gap: 0.55rem; margin-top: 0.9rem; }
.result-next .go { margin-top: 0; }
a.go, button.go {
  display: inline-block;
  margin-top: 0.2rem;
  background: var(--acid);
  color: var(--ink);
  text-decoration: none;
  border: 0;
  border-radius: 999px;
  padding: 0.5rem 0.95rem;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
a.go.ghost, button.go.ghost { background: transparent; color: var(--paper); border: 1px solid var(--line); }
.username-card {
  width: min(26rem, 100%);
  margin: 2rem auto 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 1.4rem 1.5rem;
  text-align: center;
}
.username-card h2 { margin: 0.3rem 0 0.6rem; font-family: var(--font-display); font-weight: 400; letter-spacing: 0.04em; font-size: 2rem; }
.username-card p { color: var(--muted); line-height: 1.45; }
.username-card form { display: flex; flex-direction: column; gap: 0.7rem; }
.username-card input {
  width: 100%;
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.6rem 0.75rem;
  font: inherit;
}
.username-card button {
  background: var(--acid);
  color: var(--ink);
  border: 0;
  border-radius: 999px;
  padding: 0.55rem 0.95rem;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
.username-card .hint { margin: 0; font-size: 0.85rem; text-align: left; }
.username-card .password-row button {
  background: transparent;
  color: var(--muted);
  border: 0;
  border-radius: 0;
  padding: 0 0.4rem;
  font-weight: 400;
  font-size: 0.8rem;
}
.username-card .error { color: var(--bad); min-height: 1.2rem; }
.auth-card {
  width: min(24rem, 100%);
  margin: 1.5rem auto 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 1.6rem 1.4rem 1.3rem;
  text-align: center;
}
.auth-card h2 { margin: 0.2rem 0 1rem; font-family: var(--font-display); font-weight: 400; letter-spacing: 0.04em; font-size: 2.4rem; }
.auth-card form { display: flex; flex-direction: column; gap: 0.7rem; }
.auth-card form[hidden] { display: none; }
.auth-card input {
  width: 100%;
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem 0.8rem;
  font: inherit;
}
.password-row { position: relative; }
.password-row input { padding-right: 4.2rem; }
.password-row button {
  position: absolute;
  right: 0.35rem;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  color: var(--muted);
  border: 0;
  font: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}
.auth-primary, .auth-google {
  display: block;
  width: 100%;
  border-radius: 8px;
  padding: 0.75rem 0.9rem;
  font: inherit;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
}
.auth-primary { background: var(--acid); color: var(--ink); border: 0; }
.auth-google {
  background: transparent;
  color: var(--paper);
  border: 1px solid var(--line);
  margin-top: 0.15rem;
}
.auth-google[hidden], .auth-or[hidden] { display: none; }
.auth-or { display: flex; align-items: center; gap: 0.7rem; margin: 0.95rem 0 0.7rem; color: var(--muted); font-size: 0.75rem; letter-spacing: 0.12em; }
.auth-or::before, .auth-or::after { content: ""; height: 1px; flex: 1; background: var(--line); }
.auth-links, .auth-switch { margin: 0.85rem 0 0; color: var(--muted); font-size: 0.92rem; }
.auth-links a, .auth-switch a { color: var(--paper); }
.auth-card .error { color: var(--bad); min-height: 1.2rem; margin: 0.7rem 0 0; }

body.stats main { width: min(44rem, calc(100% - 2rem)); }
.scoreboard { display: flex; flex-direction: column; gap: 0.85rem; }
.score-title {
  margin: 0.15rem 0 0.2rem;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(3.4rem, 12vw, 5.6rem);
  letter-spacing: 0.03em;
  line-height: 0.82;
}
.score-line { margin: 0; color: var(--muted); font-size: 1.02rem; }
.streak-card {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.15rem 1.15rem;
  align-items: end;
  margin-top: 0.4rem;
  padding: 1.15rem 1.25rem 1.05rem;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  background:
    radial-gradient(90% 120% at 100% 0%, color-mix(in srgb, var(--acid) 28%, transparent), transparent 58%),
    var(--panel);
}
.streak-num {
  margin: 0;
  grid-row: span 2;
  font-family: var(--font-display);
  font-size: clamp(5.2rem, 20vw, 8.2rem);
  line-height: 0.78;
  color: var(--acid);
}
.streak-label {
  margin: 0;
  align-self: end;
  font-family: var(--font-display);
  font-size: clamp(2rem, 6vw, 2.8rem);
  letter-spacing: 0.04em;
  line-height: 0.9;
}
.streak-note { margin: 0; color: var(--muted); }
.score-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.65rem; }
.score-tile, .rate-card, .form-card, .practice-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
}
.score-tile { padding: 0.85rem 0.85rem 0.75rem; }
.score-tile .num, .practice-card .num {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 8vw, 3.2rem);
  line-height: 0.85;
}
.score-tile p, .practice-card p, .form-card h3, .rate-copy p {
  margin: 0.35rem 0 0;
  color: var(--muted);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.rate-card { display: flex; align-items: center; gap: 1rem; padding: 0.85rem 1rem; }
.ring {
  width: 4.6rem;
  height: 4.6rem;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: conic-gradient(var(--acid) calc(var(--pct) * 1%), var(--line) 0);
  flex: none;
}
.ring span {
  width: 3.35rem;
  height: 3.35rem;
  border-radius: 50%;
  background: var(--panel);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 1.45rem;
}
.rate-copy strong { display: block; font-size: 1.05rem; font-weight: 500; }
.form-card, .practice-card { padding: 0.95rem 1rem 1rem; }
.form-card h3 { margin-top: 0; }
.form-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 0.38rem; margin-top: 0.75rem; }
.day {
  aspect-ratio: 1;
  border-radius: 7px;
  background: color-mix(in srgb, var(--paper) 10%, transparent);
}
.day.won { background: var(--acid); }
.day.lost { background: var(--bad); }
.day.draw { background: color-mix(in srgb, var(--paper) 42%, transparent); }
.game-pick { display: flex; flex-direction: column; gap: 0.35rem; }
.game-pick span {
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}
.game-pick select {
  font: inherit;
  color: var(--paper);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
}
.practice-card[hidden], .score-actions a[hidden] { display: none; }
.day.today { box-shadow: inset 0 0 0 2px var(--paper); }
.practice-card { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.6rem; }
.score-actions { display: flex; flex-wrap: wrap; gap: 0.6rem; margin-top: 0.3rem; }
.score-actions .go { margin-top: 0; }
@media (max-width: 520px) {
  .streak-card { grid-template-columns: 1fr; }
  .streak-num { grid-row: auto; }
}
.auth-card .hint { color: var(--muted); font-size: 0.85rem; margin: 0; text-align: left; }

@media (max-width: 700px) {
  .top { flex-direction: column; align-items: stretch; gap: 0.85rem; padding: 1rem; }
  .top:has(.gamel-logo) {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    column-gap: 0.6rem;
    row-gap: 0.35rem;
  }
  .top:has(.gamel-logo) .brand-block { display: contents; }
  .top:has(.gamel-logo) .mark { grid-column: 1; grid-row: 1; }
  .top:has(.gamel-logo) .lang-switch { grid-column: 2; grid-row: 1; justify-self: end; }
  .top:has(.gamel-logo) .tg-menu-mount { grid-column: 3; grid-row: 1; }
  .top:has(.gamel-logo) h1.game-title { grid-column: 1 / -1; grid-row: 2; }
  .mark img.gamel-logo { width: 104px; }
  .who { justify-content: flex-start; }
  .account-actions { flex: 1; }
  .account-actions button { flex: 1; white-space: nowrap; font-size: 0.92rem; padding: 0.45rem 0.55rem; }
  main { width: min(100% - 1.5rem, 40rem); padding-top: 1.6rem; }
  .lives { letter-spacing: 0.18em; font-size: 1.7rem; }
  .keys { max-width: 22rem; }
  .keys button { width: 2.55rem; height: 2.95rem; font-size: 1rem; }
  .note-actions { flex-direction: column; align-items: stretch; }
  .pill { text-align: center; }
  .notes { margin-top: 2.5rem; }
}
