:root {
  --ink: #171915;
  --ink-soft: #2a2d27;
  --paper: #e9dfca;
  --paper-light: #f4ecd9;
  --paper-dark: #c8bda5;
  --signal: #e4b84b;
  --red: #b53f38;
  --red-dark: #772a28;
  --blue: #315f8d;
  --blue-dark: #203e60;
  --neutral: #aaa087;
  --white: #fffaf0;
  --font-display: "Avenir Next Condensed", "DIN Condensed", "Franklin Gothic Condensed", sans-serif;
  --font-copy: "Iowan Old Style", "Palatino Linotype", Palatino, serif;
  --safe-top: max(18px, env(safe-area-inset-top));
  --safe-bottom: max(18px, env(safe-area-inset-bottom));
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--ink);
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100svh;
  color: var(--ink);
  background:
    radial-gradient(circle at 18% 12%, rgba(228, 184, 75, 0.1), transparent 30rem),
    radial-gradient(circle at 85% 78%, rgba(49, 95, 141, 0.12), transparent 28rem),
    #171915;
  font-family: var(--font-copy);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.paper-noise {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  opacity: 0.34;
  background-image:
    repeating-linear-gradient(0deg, transparent 0 3px, rgba(255, 255, 255, 0.014) 3px 4px),
    repeating-linear-gradient(90deg, transparent 0 7px, rgba(0, 0, 0, 0.025) 7px 8px);
}

.app-shell {
  width: 100%;
  min-height: 100svh;
}

.boot-screen {
  min-height: 100svh;
  display: grid;
  place-items: center;
}

.stamp {
  color: var(--signal);
  border: 3px solid currentColor;
  padding: 0.6rem 1rem 0.4rem;
  font: 800 1.3rem/1 var(--font-display);
  letter-spacing: 0.16em;
  transform: rotate(-3deg);
}

.eyebrow,
.classification,
.role-badge,
.card-index,
.card-role,
.key-index {
  font-family: var(--font-display);
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.eyebrow {
  display: block;
  font-size: 0.7rem;
}

.button {
  min-height: 48px;
  border: 0;
  border-radius: 0;
  padding: 0.8rem 1.25rem 0.68rem;
  font: 800 0.86rem/1 var(--font-display);
  letter-spacing: 0.11em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 140ms ease, filter 140ms ease, box-shadow 140ms ease;
}

.button:not(:disabled):active {
  transform: translateY(2px);
}

.button:not(:disabled):hover {
  filter: brightness(1.06);
}

.button:focus-visible,
.word-card:focus-visible,
.number-key:focus-visible,
.text-button:focus-visible,
.code-chip:focus-visible {
  outline: 3px solid var(--signal);
  outline-offset: 3px;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.43;
}

.button-signal {
  color: var(--ink);
  background: var(--signal);
  box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.28);
}

.button-ink {
  color: var(--paper-light);
  background: var(--ink);
  box-shadow: 4px 4px 0 rgba(21, 23, 19, 0.25);
}

.button-paper {
  color: var(--ink);
  background: var(--paper-light);
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.25);
}

.button-outline {
  color: inherit;
  border: 1px solid currentColor;
  background: transparent;
}

.button-ghost {
  color: var(--ink);
  background: transparent;
}

.button-full {
  width: 100%;
}

.button-small {
  min-height: 38px;
  padding: 0.58rem 0.7rem 0.48rem;
  font-size: 0.69rem;
}

.text-button {
  min-height: 40px;
  color: inherit;
  border: 0;
  border-bottom: 1px solid currentColor;
  background: transparent;
  padding: 0.4rem 0;
  font: 700 0.75rem/1 var(--font-display);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
}

/* Landing */
.landing-screen {
  min-height: 100svh;
  padding: calc(var(--safe-top) + 1.5rem) clamp(1rem, 4vw, 3rem) var(--safe-bottom);
  color: var(--paper-light);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: clamp(1.5rem, 4vh, 3.25rem);
  overflow: hidden;
}

.masthead {
  width: min(100%, 900px);
  margin: 0 auto;
  text-align: center;
  animation: rise-in 500ms both;
}

.classification {
  color: var(--signal);
  font-size: 0.7rem;
}

.title-lockup {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: clamp(0.7rem, 2vw, 1.5rem);
  align-items: center;
  margin: 0.45rem 0 0.2rem;
}

.title-lockup h1 {
  margin: 0;
  font: 900 clamp(3.3rem, 13vw, 8rem)/0.82 var(--font-display);
  letter-spacing: -0.045em;
}

.title-lockup h1 span {
  color: var(--signal);
}

.title-rule {
  height: 4px;
  background: var(--paper-light);
  box-shadow: 0 8px 0 var(--red);
}

.lead {
  max-width: 42rem;
  margin: 1rem auto 0;
  color: rgba(244, 236, 217, 0.75);
  font-size: clamp(1rem, 2.6vw, 1.3rem);
}

.entry-grid {
  width: min(100%, 920px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1.08fr 0.92fr;
  gap: clamp(0.8rem, 2vw, 1.25rem);
}

.entry-card {
  position: relative;
  min-width: 0;
  padding: clamp(1.2rem, 3vw, 2rem);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1.4rem;
  clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 18px, 100% 100%, 0 100%);
  animation: rise-in 500ms 100ms both;
}

.entry-primary {
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(23, 25, 21, 0.045) 1px, transparent 1px) 0 0 / 18px 18px,
    var(--paper);
}

.entry-secondary {
  color: var(--paper-light);
  border: 1px solid rgba(244, 236, 217, 0.3);
  background: rgba(244, 236, 217, 0.055);
  animation-delay: 180ms;
}

.entry-number {
  position: absolute;
  top: 0.8rem;
  right: 1rem;
  opacity: 0.13;
  font: 900 4rem/1 var(--font-display);
}

.entry-card h2 {
  margin: 0.15rem 0 0.35rem;
  font: 800 clamp(1.6rem, 4vw, 2.4rem)/1 var(--font-display);
  text-transform: uppercase;
}

.entry-card p {
  margin: 0;
}

.entry-card .eyebrow {
  color: var(--red);
}

.entry-secondary .eyebrow {
  color: var(--signal);
}

.join-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.65rem;
}

.join-form label {
  grid-column: 1 / -1;
  font: 700 0.67rem/1 var(--font-display);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.join-form input {
  width: 100%;
  min-width: 0;
  height: 50px;
  color: var(--paper-light);
  border: 0;
  border-bottom: 2px solid var(--signal);
  border-radius: 0;
  outline: 0;
  background: rgba(0, 0, 0, 0.23);
  padding: 0.55rem 0.75rem 0.4rem;
  font: 800 1.45rem/1 var(--font-display);
  letter-spacing: 0.22em;
  text-transform: uppercase;
}

.landing-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  color: rgba(244, 236, 217, 0.55);
  font: 700 0.62rem/1 var(--font-display);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.landing-footer i {
  width: 4px;
  height: 4px;
  background: var(--signal);
  transform: rotate(45deg);
}

/* Waiting room */
.waiting-screen {
  width: min(100%, 700px);
  min-height: 100svh;
  margin: 0 auto;
  padding: var(--safe-top) clamp(1.2rem, 5vw, 3rem) var(--safe-bottom);
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(23, 25, 21, 0.045) 1px, transparent 1px) 0 0 / 22px 22px,
    var(--paper);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1rem;
}

.compact-header,
.game-header,
.game-identity,
.key-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.role-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0.35rem 0.55rem 0.25rem;
  color: var(--paper-light);
  background: var(--ink);
  font-size: 0.65rem;
}

.waiting-radar {
  position: relative;
  width: clamp(112px, 28vw, 170px);
  aspect-ratio: 1;
  margin: 1rem auto 0;
  border: 1px solid rgba(23, 25, 21, 0.28);
  border-radius: 50%;
  display: grid;
  place-items: center;
}

.waiting-radar::before,
.waiting-radar::after,
.waiting-radar i {
  content: "";
  position: absolute;
  border: 1px solid rgba(23, 25, 21, 0.22);
  border-radius: 50%;
}

.waiting-radar::before { inset: 22%; }
.waiting-radar::after { inset: 42%; background: var(--red); border: 0; }
.waiting-radar i:first-child { width: 1px; height: 100%; border: 0; background: rgba(23, 25, 21, 0.22); border-radius: 0; }
.waiting-radar i:nth-child(2) { width: 100%; height: 1px; border: 0; background: rgba(23, 25, 21, 0.22); border-radius: 0; }
.waiting-radar i:last-child {
  inset: 0 50% 50% 0;
  border: 0;
  border-right: 2px solid var(--red);
  border-radius: 100% 0 0;
  transform-origin: bottom right;
  animation: radar 2.2s linear infinite;
}

.waiting-copy {
  text-align: center;
}

.waiting-copy .eyebrow {
  color: var(--red);
}

.waiting-copy h1 {
  margin: 0.35rem 0 0.5rem;
  font: 850 clamp(2rem, 8vw, 3.8rem)/0.95 var(--font-display);
  text-transform: uppercase;
}

.waiting-copy p:last-child {
  max-width: 31rem;
  margin: 0 auto;
}

.game-code {
  display: flex;
  justify-content: center;
  gap: clamp(0.35rem, 2vw, 0.75rem);
}

.game-code span {
  width: clamp(43px, 13vw, 72px);
  aspect-ratio: 0.83;
  display: grid;
  place-items: center;
  color: var(--paper-light);
  background: var(--ink);
  font: 900 clamp(1.7rem, 8vw, 3rem)/1 var(--font-display);
  box-shadow: 5px 6px 0 var(--red);
}

.waiting-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.7rem;
}

.field-note {
  padding: 0.9rem 1rem;
  border-left: 5px solid var(--red);
  background: rgba(23, 25, 21, 0.065);
  display: grid;
  gap: 0.15rem;
  font-size: 0.9rem;
}

.field-note strong {
  font-family: var(--font-display);
  text-transform: uppercase;
}

/* Shared game chrome */
.game-screen {
  width: min(100%, 1120px);
  min-height: 100svh;
  margin: 0 auto;
  padding: var(--safe-top) clamp(0.55rem, 2.4vw, 1.7rem) var(--safe-bottom);
  background:
    linear-gradient(90deg, rgba(23, 25, 21, 0.04) 1px, transparent 1px) 0 0 / 20px 20px,
    var(--paper);
}

.game-header {
  min-height: 46px;
}

.code-chip {
  min-height: 30px;
  color: var(--ink);
  border: 1px dashed currentColor;
  background: transparent;
  padding: 0.35rem 0.5rem 0.24rem;
  font: 800 0.72rem/1 var(--font-display);
  letter-spacing: 0.15em;
  cursor: pointer;
}

.code-chip.static {
  cursor: default;
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(2, minmax(72px, 1fr));
  gap: 0.35rem;
}

.score {
  min-width: 80px;
  padding: 0.35rem 0.5rem 0.27rem;
  color: var(--white);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  opacity: 0.66;
  border: 2px solid transparent;
  font-family: var(--font-display);
}

.score.is-active {
  opacity: 1;
  border-color: var(--signal);
}

.score span {
  font-size: clamp(0.55rem, 1.8vw, 0.74rem);
  letter-spacing: 0.08em;
}

.score strong {
  font-size: 1.15rem;
}

.score-red { background: var(--red); }
.score-blue { background: var(--blue); }

.turn-banner,
.result-banner {
  position: relative;
  margin: 0.65rem 0 0;
  padding: clamp(0.75rem, 2vw, 1.15rem) clamp(0.85rem, 2.5vw, 1.4rem);
  color: var(--white);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  overflow: hidden;
}

.team-red { background: var(--red-dark); }
.team-blue { background: var(--blue-dark); }

.turn-banner::after,
.result-banner::after,
.clue-console::after,
.clue-status::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.13;
  pointer-events: none;
  background: repeating-linear-gradient(130deg, transparent 0 12px, currentColor 12px 14px);
}

.turn-banner h1 {
  position: relative;
  margin: 0.1rem 0 0;
  font: 900 clamp(1.45rem, 5vw, 2.65rem)/0.94 var(--font-display);
  letter-spacing: -0.02em;
}

.turn-counter {
  position: relative;
  min-width: 92px;
  text-align: right;
}

.turn-counter strong {
  display: block;
  color: var(--signal);
  font: 900 clamp(1.7rem, 6vw, 2.7rem)/0.82 var(--font-display);
}

.turn-counter span {
  font: 700 0.62rem/1 var(--font-display);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.action-feed {
  min-height: 30px;
  margin: 0.48rem 0;
  padding: 0.35rem 0.55rem 0.3rem;
  border: 1px dashed rgba(23, 25, 21, 0.3);
  font: 700 clamp(0.68rem, 2vw, 0.8rem)/1.2 var(--font-display);
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.action-feed span {
  display: inline-block;
  width: 7px;
  height: 7px;
  margin-right: 0.5rem;
  border-radius: 50%;
  background: var(--signal);
}

/* Board */
.board-screen {
  display: flex;
  flex-direction: column;
}

.word-grid {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-template-rows: repeat(5, minmax(52px, 1fr));
  gap: clamp(4px, 1vw, 9px);
}

.word-card {
  position: relative;
  min-width: 0;
  min-height: 52px;
  border: 1px solid rgba(23, 25, 21, 0.28);
  border-radius: 0;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.45), transparent 45%),
    var(--paper-light);
  padding: clamp(0.55rem, 1.5vw, 0.9rem) 0.25rem 0.3rem;
  box-shadow: 0 2px 0 rgba(23, 25, 21, 0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, filter 120ms ease;
}

.word-card:not(:disabled):active {
  transform: scale(0.96);
  box-shadow: none;
}

.word-card:disabled.is-hidden {
  opacity: 0.68;
  cursor: default;
}

.card-index {
  position: absolute;
  top: 0.22rem;
  left: 0.3rem;
  color: rgba(23, 25, 21, 0.42);
  font-size: clamp(0.42rem, 1.2vw, 0.58rem);
}

.card-word {
  width: 100%;
  font: 900 clamp(0.54rem, 2.3vw, 1rem)/0.95 var(--font-display);
  letter-spacing: -0.01em;
  text-align: center;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.card-role {
  position: absolute;
  right: 0.18rem;
  bottom: 0.12rem;
  font-size: clamp(0.36rem, 1.05vw, 0.5rem);
  opacity: 0.8;
}

.word-card.is-red,
.word-card.is-blue,
.word-card.is-assassin {
  color: var(--white);
  border-color: rgba(255, 255, 255, 0.22);
}

.word-card.is-red { background: var(--red); }
.word-card.is-blue { background: var(--blue); }
.word-card.is-neutral { background: var(--neutral); }
.word-card.is-assassin {
  background:
    repeating-linear-gradient(135deg, #0b0c0a 0 9px, #1d1f1b 9px 18px);
  box-shadow: inset 0 0 0 2px var(--signal);
}

.word-card.is-red::after,
.word-card.is-blue::after,
.word-card.is-neutral::after {
  content: "";
  position: absolute;
  width: 70%;
  height: 1px;
  background: currentColor;
  opacity: 0.25;
  transform: rotate(-18deg);
}

.board-controls {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.8rem;
  padding-top: 0.6rem;
}

.board-controls p {
  margin: 0;
  color: rgba(23, 25, 21, 0.72);
  font-size: clamp(0.74rem, 2vw, 0.9rem);
}

/* Secret key */
.key-screen {
  color: var(--paper-light);
  background:
    repeating-linear-gradient(90deg, transparent 0 21px, rgba(255, 255, 255, 0.018) 21px 22px),
    var(--ink);
  display: flex;
  flex-direction: column;
}

.role-secret {
  color: var(--ink);
  background: var(--signal);
}

.key-screen .code-chip {
  color: var(--paper-light);
}

.privacy-cover {
  flex: 1;
  max-width: 38rem;
  margin: 0 auto;
  padding: 2rem 1.2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.privacy-cover .eyebrow {
  color: var(--signal);
}

.privacy-cover h1 {
  margin: 0.4rem 0 0.8rem;
  font: 900 clamp(2.3rem, 10vw, 4.8rem)/0.9 var(--font-display);
  text-transform: uppercase;
}

.privacy-cover p:not(.eyebrow) {
  max-width: 28rem;
  margin: 0 0 1.5rem;
  color: rgba(244, 236, 217, 0.7);
}

.privacy-symbol {
  width: 92px;
  height: 58px;
  margin-bottom: 2rem;
  border: 3px solid var(--signal);
  border-radius: 60% 15% 60% 15%;
  display: grid;
  place-items: center;
  transform: rotate(-8deg);
}

.privacy-symbol span {
  width: 22px;
  height: 22px;
  border: 3px solid var(--signal);
  border-radius: 50%;
  box-shadow: 0 0 0 6px rgba(228, 184, 75, 0.12);
}

.clue-console,
.clue-status {
  position: relative;
  margin: 0.65rem 0 0;
  padding: clamp(0.9rem, 3vw, 1.4rem);
  overflow: hidden;
}

.clue-console > *,
.clue-status > * {
  position: relative;
  z-index: 1;
}

.clue-console-copy h2 {
  margin: 0.18rem 0 0.2rem;
  font: 900 clamp(1.55rem, 6vw, 2.5rem)/1 var(--font-display);
  text-transform: uppercase;
}

.clue-console-copy p {
  margin: 0;
  color: rgba(255, 250, 240, 0.72);
  font-size: 0.84rem;
}

.number-grid {
  display: grid;
  grid-template-columns: repeat(11, minmax(30px, 1fr));
  gap: 0.35rem;
  margin: 0.85rem 0 0.65rem;
}

.number-key {
  min-width: 0;
  aspect-ratio: 1;
  color: var(--white);
  border: 1px solid rgba(255, 255, 255, 0.38);
  border-radius: 0;
  background: rgba(0, 0, 0, 0.22);
  font: 900 clamp(0.85rem, 3vw, 1.25rem)/1 var(--font-display);
  cursor: pointer;
}

.number-key[aria-pressed="true"] {
  color: var(--ink);
  border-color: var(--signal);
  background: var(--signal);
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.32);
}

.number-unlimited {
  font-family: Georgia, serif;
}

.clue-status {
  display: grid;
  gap: 0.15rem;
}

.clue-status strong {
  font: 900 clamp(1.5rem, 6vw, 2.4rem)/1 var(--font-display);
}

.clue-status small {
  color: rgba(255, 255, 255, 0.72);
  font: 700 0.7rem/1 var(--font-display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.key-toolbar {
  margin-top: 0.55rem;
}

.key-toolbar .scoreboard {
  width: min(100%, 340px);
}

.key-screen .action-feed {
  border-color: rgba(244, 236, 217, 0.25);
}

.key-grid {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-template-rows: repeat(5, minmax(48px, 1fr));
  gap: clamp(4px, 1vw, 8px);
}

.key-card {
  position: relative;
  min-width: 0;
  min-height: 48px;
  padding: 0.75rem 0.2rem 0.25rem;
  display: grid;
  place-items: center;
  color: var(--white);
  border: 1px solid rgba(255, 255, 255, 0.18);
  overflow: hidden;
}

.key-card strong {
  width: 100%;
  font: 800 clamp(0.49rem, 2.25vw, 0.94rem)/0.92 var(--font-display);
  letter-spacing: -0.01em;
  text-align: center;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.key-card i {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--signal);
  background: rgba(0, 0, 0, 0.52);
  font: 900 2rem/1 var(--font-display);
  font-style: normal;
}

.key-index {
  position: absolute;
  top: 0.18rem;
  left: 0.25rem;
  font-size: clamp(0.38rem, 1.1vw, 0.5rem);
  opacity: 0.58;
}

.key-red { background: var(--red); }
.key-blue { background: var(--blue); }
.key-neutral { color: var(--ink); background: var(--neutral); }
.key-assassin {
  color: var(--signal);
  background: repeating-linear-gradient(135deg, #050605 0 8px, #1d1f1b 8px 16px);
  box-shadow: inset 0 0 0 2px var(--signal);
}

.key-legend {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.35rem;
  padding-top: 0.55rem;
}

.key-legend span {
  padding: 0.3rem 0.2rem 0.22rem;
  text-align: center;
  font: 800 0.56rem/1 var(--font-display);
  letter-spacing: 0.08em;
}

.legend-red { background: var(--red); }
.legend-blue { background: var(--blue); }
.legend-neutral { color: var(--ink); background: var(--neutral); }
.legend-assassin { color: var(--signal); border: 1px solid var(--signal); background: #050605; }

/* Result */
.result-banner {
  display: block;
  text-align: center;
  padding-block: 1.2rem;
}

.result-banner > * {
  position: relative;
  z-index: 1;
}

.result-banner h2 {
  margin: 0.2rem 0;
  font: 900 clamp(2rem, 8vw, 4rem)/0.9 var(--font-display);
}

.result-banner p {
  margin: 0.35rem 0 0.8rem;
}

/* Dialog, toast, connectivity */
.confirm-dialog {
  width: min(calc(100% - 2rem), 440px);
  color: var(--ink);
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 0;
}

.confirm-dialog::backdrop {
  background: rgba(8, 9, 8, 0.8);
  backdrop-filter: blur(4px);
}

.confirm-sheet {
  position: relative;
  padding: 1.5rem;
  background:
    linear-gradient(90deg, rgba(23, 25, 21, 0.05) 1px, transparent 1px) 0 0 / 18px 18px,
    var(--paper-light);
  box-shadow: 9px 10px 0 var(--red);
}

.confirm-sheet::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  border-style: solid;
  border-width: 0 24px 24px 0;
  border-color: transparent var(--ink) transparent transparent;
}

.confirm-sheet .eyebrow {
  color: var(--red);
}

.confirm-sheet h2 {
  margin: 0.25rem 0;
  font: 900 clamp(1.9rem, 8vw, 3rem)/0.95 var(--font-display);
  text-transform: uppercase;
}

.confirm-sheet p {
  margin: 0.6rem 0 1.2rem;
}

.confirm-actions {
  display: grid;
  grid-template-columns: 0.7fr 1.3fr;
  gap: 0.55rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 2.4rem);
  z-index: 20;
  max-width: calc(100% - 2rem);
  color: var(--ink);
  background: var(--signal);
  padding: 0.75rem 1rem 0.65rem;
  box-shadow: 5px 5px 0 rgba(0, 0, 0, 0.34);
  font: 800 0.76rem/1.2 var(--font-display);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  opacity: 0;
  transform: translate(-50%, 16px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.toast.is-error {
  color: var(--white);
  background: var(--red);
}

.connection-indicator {
  position: fixed;
  right: max(10px, env(safe-area-inset-right));
  bottom: max(8px, env(safe-area-inset-bottom));
  z-index: 15;
  color: rgba(244, 236, 217, 0.7);
  background: rgba(23, 25, 21, 0.86);
  padding: 0.3rem 0.5rem 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font: 700 0.56rem/1 var(--font-display);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  pointer-events: none;
}

.connection-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #777;
}

.connection-indicator[data-state="online"] .connection-dot { background: #78b768; box-shadow: 0 0 0 3px rgba(120, 183, 104, 0.15); }
.connection-indicator[data-state="connecting"] .connection-dot { background: var(--signal); animation: blink 900ms infinite; }
.connection-indicator[data-state="offline"] .connection-dot { background: var(--red); }
.connection-indicator[data-state="idle"] { opacity: 0.5; }

@keyframes rise-in {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes radar {
  to { transform: rotate(360deg); }
}

@keyframes blink {
  50% { opacity: 0.25; }
}

@media (max-width: 680px) {
  .landing-screen {
    justify-content: flex-start;
  }

  .entry-grid {
    grid-template-columns: 1fr;
  }

  .entry-card {
    gap: 0.85rem;
  }

  .landing-footer {
    flex-wrap: wrap;
  }

  .game-header {
    align-items: flex-start;
  }

  .score {
    min-width: 68px;
    display: grid;
    gap: 0;
  }

  .board-controls {
    grid-template-columns: 1fr auto;
  }

  .number-grid {
    grid-template-columns: repeat(6, 1fr);
  }

  .number-key {
    aspect-ratio: 1.35;
  }
}

@media (max-width: 380px) {
  .game-screen {
    padding-inline: 0.35rem;
  }

  .role-badge {
    font-size: 0.56rem;
  }

  .word-grid,
  .key-grid {
    gap: 3px;
  }

  .card-word,
  .key-card strong {
    font-size: 0.49rem;
  }

  .board-controls p {
    display: none;
  }

  .board-controls {
    grid-template-columns: 1fr;
  }
}

@media (orientation: landscape) and (max-height: 620px) {
  .game-screen {
    padding-top: max(6px, env(safe-area-inset-top));
    padding-bottom: max(6px, env(safe-area-inset-bottom));
  }

  .game-header {
    min-height: 34px;
  }

  .turn-banner,
  .clue-console,
  .clue-status {
    padding-block: 0.5rem;
  }

  .turn-banner h1 {
    font-size: 1.4rem;
  }

  .action-feed {
    margin-block: 0.25rem;
    min-height: 24px;
  }

  .board-controls {
    padding-top: 0.3rem;
  }

  .button {
    min-height: 40px;
  }

  .key-toolbar {
    margin-top: 0.3rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
