@import url("https://fonts.googleapis.com/css2?family=Press+Start+2P&family=VT323&display=swap");

:root {
  --paper: #e8dbc2;
  --paper-dark: #d4c1a1;
  --panel: #efe1c3;
  --panel-dark: #dbc59c;
  --panel-border: #6b5241;
  --wood: #33251b;
  --wood-light: #4a3525;
  --accent: #c53d2f;
  --accent-dark: #8f2a23;
  --accent-soft: #e0b06a;
  --danger: #b22f28;
  --success: #3d6b3f;
  --ink: #2b231b;
  --ink-muted: #5d4b3a;
  --highlight: #f6efd9;
  --shadow: rgba(35, 23, 14, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "VT323", "Courier New", monospace;
  background: var(--paper);
  color: var(--ink);
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(circle at 10% 20%, rgba(255, 255, 255, 0.35), transparent 50%),
    radial-gradient(circle at 80% 10%, rgba(255, 255, 255, 0.25), transparent 55%),
    repeating-linear-gradient(
      45deg,
      rgba(64, 47, 35, 0.08) 0,
      rgba(64, 47, 35, 0.08) 2px,
      transparent 2px,
      transparent 6px
    );
  opacity: 0.45;
  pointer-events: none;
}

body::after {
  content: "";
  position: fixed;
  width: 420px;
  height: 600px;
  left: 10%;
  top: 120px;
  background: radial-gradient(ellipse at center, rgba(197, 61, 47, 0.9), rgba(197, 61, 47, 0.15) 65%, transparent 70%);
  transform: rotate(-15deg);
  opacity: 0.55;
  pointer-events: none;
}

.screen {
  max-width: 1200px;
  margin: 0 auto;
  padding: 52px 20px 64px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: relative;
}

.screen::before,
.screen::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 18px;
  background:
    repeating-linear-gradient(
      45deg,
      var(--accent) 0,
      var(--accent) 6px,
      #f3e6cf 6px,
      #f3e6cf 12px
    );
  border: 3px solid var(--panel-border);
  border-left: none;
  border-right: none;
  pointer-events: none;
}

.screen::before {
  top: 0;
}

.screen::after {
  bottom: 0;
}

.title {
  text-align: center;
  animation: rise 0.8s ease-out;
  position: relative;
  z-index: 1;
}

.audio-toggle {
  position: fixed;
  top: 24px;
  right: 24px;
  width: 44px;
  height: 44px;
  border-radius: 6px;
  border: 3px solid var(--panel-border);
  background: linear-gradient(180deg, #f5e6c7, #d2b481);
  color: var(--ink);
  display: grid;
  place-items: center;
  box-shadow: 0 6px 0 rgba(75, 55, 40, 0.35), 0 10px 18px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  z-index: 40;
}

.audio-toggle:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 6px 0 rgba(75, 55, 40, 0.4), 0 12px 18px rgba(0, 0, 0, 0.3);
}

.audio-toggle:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.audio-toggle svg {
  width: 22px;
  height: 22px;
}

.audio-toggle .speaker {
  fill: currentColor;
}

.audio-toggle .wave {
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.audio-toggle[data-state="off"] {
  color: var(--ink-muted);
  background: linear-gradient(180deg, #e7d3af, #c29a61);
}

.audio-toggle[data-state="off"]::after {
  content: "";
  position: absolute;
  width: 3px;
  height: 28px;
  background: var(--danger);
  transform: rotate(-45deg);
  border-radius: 999px;
  opacity: 0.8;
}

.audio-toggle[data-state="off"] .wave {
  opacity: 0.2;
}

.audio-toggle[data-state="on"] {
  border-color: var(--accent);
  box-shadow: 0 6px 0 rgba(75, 55, 40, 0.35), 0 0 18px rgba(197, 61, 47, 0.35);
}


.logo {
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: clamp(1.6rem, 3vw, 2.6rem);
  letter-spacing: 3px;
  color: var(--ink);
  text-shadow: 3px 3px 0 rgba(197, 61, 47, 0.35);
}

.subtitle {
  margin-top: 12px;
  color: var(--ink-muted);
  font-size: 1.1rem;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.panel {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.4), transparent),
    linear-gradient(180deg, var(--panel), var(--panel-dark));
  border: 4px solid var(--panel-border);
  border-radius: 10px;
  padding: 24px;
  box-shadow: 0 12px 0 rgba(75, 55, 40, 0.3), 0 18px 36px var(--shadow);
  animation: rise 0.8s ease-out;
  position: relative;
  overflow: hidden;
}

.panel h2 {
  margin-top: 0;
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 1rem;
  color: var(--accent-dark);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.panel h3 {
  margin-bottom: 12px;
  font-size: 1rem;
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.setup-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
}

.setup-block {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.player-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.player-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 12px;
  align-items: center;
}

.player-portrait {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  border: 3px solid var(--panel-border);
  object-fit: cover;
  image-rendering: pixelated;
  box-shadow: 0 6px 0 rgba(75, 55, 40, 0.35);
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.2s ease;
}

.player-portrait:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(18, 12, 8, 0.7);
  display: grid;
  place-items: center;
  z-index: 80;
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(90vw, 720px);
  background: var(--modal-bg, var(--panel));
  border: 4px solid var(--panel-border);
  border-radius: 10px;
  padding: 18px;
  box-shadow: 0 18px 30px rgba(0, 0, 0, 0.4);
  position: relative;
  overflow: hidden;
}

.modal-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.16), transparent 60%);
  opacity: 0.6;
  pointer-events: none;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  position: relative;
  z-index: 1;
}

.avatar-grid {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 16px;
  position: relative;
  z-index: 1;
}

.avatar-option {
  padding: 12px;
  border-radius: 8px;
  border: 3px solid var(--panel-border);
  background: var(--avatar-bg, #f2ddba);
  box-shadow: 0 6px 0 rgba(75, 55, 40, 0.35);
  cursor: pointer;
  display: grid;
  place-items: center;
  gap: 8px;
  transition: transform 0.15s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.avatar-option:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.avatar-option.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(197, 61, 47, 0.35);
}

.avatar-option img {
  width: 96px;
  height: 96px;
  border-radius: 6px;
  border: 3px solid rgba(43, 35, 27, 0.6);
  object-fit: cover;
  image-rendering: pixelated;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--ink-muted);
}

.field.checkbox {
  flex-direction: row;
  align-items: center;
  gap: 10px;
  font-size: 0.95rem;
  color: var(--ink);
}

.field.checkbox input {
  accent-color: var(--accent);
}

.field-note {
  font-size: 0.85rem;
  color: var(--ink-muted);
}

.field input,
.text-input {
  padding: 10px 12px;
  border-radius: 6px;
  border: 3px solid var(--panel-border);
  background: #f6ecd3;
  color: var(--ink);
  font-size: 1rem;
  font-family: "VT323", "Courier New", monospace;
  box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0.08);
}

.board {
  display: grid;
  grid-template-columns: minmax(220px, 280px) 1fr;
  gap: 24px;
}

.scoreboard {
  background:
    repeating-linear-gradient(
      90deg,
      rgba(197, 61, 47, 0.18) 0,
      rgba(197, 61, 47, 0.18) 8px,
      rgba(255, 255, 255, 0.05) 8px,
      rgba(255, 255, 255, 0.05) 16px
    ),
    linear-gradient(145deg, var(--wood-light), var(--wood));
  border: 4px solid var(--panel-border);
  border-radius: 8px;
  padding: 16px;
  color: var(--highlight);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.scoreboard h2 {
  margin: 0;
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 0.9rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #f1e1c2;
}

.score-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.score-item {
  padding: 10px;
  border-radius: 6px;
  border: 2px solid rgba(247, 233, 200, 0.3);
  background: rgba(0, 0, 0, 0.3);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  font-size: 1.1rem;
  animation: pop 0.6s ease-out;
}

.score-identity {
  display: flex;
  align-items: center;
  gap: 10px;
}

.score-portrait {
  width: 40px;
  height: 40px;
  border-radius: 6px;
  border: 2px solid rgba(247, 233, 200, 0.6);
  object-fit: cover;
  image-rendering: pixelated;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
}

.score-value {
  display: flex;
  justify-content: flex-end;
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 0.8rem;
}

.score-item.active {
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(197, 61, 47, 0.5);
}

.play {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.status {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
}

.status-item {
  background: rgba(255, 255, 255, 0.6);
  border: 3px solid var(--panel-border);
  border-radius: 6px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.label {
  color: var(--ink-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.value {
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 24px;
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 0.9rem;
}

.dice-area {
  background: rgba(255, 255, 255, 0.7);
  border: 4px solid var(--panel-border);
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  overflow: hidden;
}

.dice-header {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  color: var(--ink-muted);
}

.hint {
  font-size: 0.95rem;
}

.selected-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: right;
}

.selected-score {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: flex-end;
  color: var(--ink);
}

.selected-breakdown {
  font-size: 0.95rem;
  color: var(--ink-muted);
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 280px;
}

.ritualist-card {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ritualist-portrait {
  width: 50px;
  height: 50px;
  border-radius: 8px;
  border: 3px solid var(--panel-border);
  object-fit: cover;
  image-rendering: pixelated;
  box-shadow: 0 6px 0 rgba(75, 55, 40, 0.35);
}

.status-pill {
  padding: 4px 10px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.08);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 0.6rem;
}

.status-pill[data-state="valid"] {
  background: rgba(60, 107, 63, 0.2);
  color: var(--success);
}

.status-pill[data-state="invalid"],
.status-pill[data-state="farkle"] {
  background: rgba(123, 43, 27, 0.2);
  color: var(--danger);
}

.dice-tray {
  min-height: 120px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(70px, 1fr));
  gap: 12px;
  padding: 12px;
  border-radius: 6px;
  border: 3px dashed rgba(107, 82, 65, 0.6);
  background: rgba(255, 255, 255, 0.4);
  transition: border-color 0.2s ease, background 0.2s ease;
}

.dice-tray.clickable {
  cursor: pointer;
  border-color: rgba(197, 61, 47, 0.7);
  background: rgba(255, 255, 255, 0.55);
}

.dice-tray.clickable:hover {
  border-color: var(--accent-dark);
}

.dice-tray.farkle {
  border-color: var(--danger);
  background: rgba(123, 43, 27, 0.08);
}

.dice-tray.farkle .die {
  opacity: 0.55;
  filter: grayscale(0.3);
}

.game.farkle-turn .status,
.game.farkle-turn .dice-area {
  animation: threadSnap 0.6s ease-in-out;
}

.game.farkle-turn .dice-area::after {
  content: "FARKLE";
  position: absolute;
  top: 10px;
  right: 14px;
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 0.6rem;
  letter-spacing: 3px;
  color: var(--danger);
  opacity: 0;
  animation: ravenCroak 0.8s ease-out;
  pointer-events: none;
}

.game.hot-dice .dice-area {
  animation: candleFlare 0.9s ease-in-out;
  box-shadow: 0 0 18px rgba(247, 233, 200, 0.5);
}

.dice-placeholder {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--ink-muted);
  padding: 32px 12px;
  background: transparent;
  border: none;
  width: 100%;
  font: inherit;
  cursor: inherit;
}

.die {
  width: 70px;
  height: 70px;
  border-radius: 6px;
  border: 3px solid var(--panel-border);
  background: linear-gradient(145deg, #fff5e2, #dec8a2);
  color: var(--ink);
  font-size: 1.4rem;
  font-family: "Press Start 2P", "Courier New", monospace;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  box-shadow: 0 6px 0 rgba(75, 55, 40, 0.35);
}

.die:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.die.selected {
  border-color: var(--accent-dark);
  box-shadow: 0 0 12px rgba(197, 61, 47, 0.4);
  transform: translateY(-3px) scale(1.02);
}

.die.rolling {
  animation: diceShuffle 0.2s ease-in-out infinite;
  border-color: rgba(197, 61, 47, 0.6);
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.btn {
  padding: 12px 16px;
  border-radius: 6px;
  border: 3px solid var(--panel-border);
  background: linear-gradient(180deg, #f6e6c9, #d1b082);
  color: var(--ink);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 0.8rem;
  font-family: "Press Start 2P", "Courier New", monospace;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  box-shadow: 0 6px 0 rgba(75, 55, 40, 0.35), 0 10px 16px rgba(0, 0, 0, 0.2);
}

.btn:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 6px 0 rgba(75, 55, 40, 0.4), 0 12px 18px rgba(0, 0, 0, 0.3);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
  box-shadow: none;
}

.btn.primary {
  background: linear-gradient(180deg, #f8d8b0, #d4a46a);
  border-color: var(--accent);
}

.btn.accent {
  background: linear-gradient(180deg, #e65a4a, #b7392d);
  border-color: var(--accent-dark);
  color: #fcefe0;
}

.btn.danger {
  background: linear-gradient(180deg, #a7372d, #74231e);
  border-color: #5b1e12;
  color: #f8e6d6;
}

.btn.ghost {
  background: transparent;
  border-color: rgba(107, 82, 65, 0.6);
  color: var(--ink-muted);
  box-shadow: none;
}

.btn.small {
  padding: 8px 10px;
  font-size: 0.8rem;
}

.message {
  min-height: 24px;
  color: var(--ink);
  font-size: 1rem;
}

.turn-transition {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 50;
  opacity: 0;
  background: radial-gradient(circle, rgba(0, 0, 0, 0.45), transparent 70%);
  transition: opacity 0.2s ease;
}

.turn-transition.active {
  opacity: 1;
}

.turn-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 28px;
  min-width: 260px;
  border-radius: 8px;
  border: 3px solid #4a3a26;
  background: linear-gradient(120deg, #2d2118, #4a3525 45%, #1e1510);
  color: #f1e1c2;
  box-shadow: 0 18px 32px rgba(0, 0, 0, 0.5);
  position: relative;
  opacity: 0;
  transform: translateY(12px) scale(0.96);
}

.turn-transition.active .turn-banner {
  animation: bannerReveal 1.9s ease-in-out both;
}

.turn-banner::before,
.turn-banner::after {
  content: "";
  position: absolute;
  width: 110px;
  height: 8px;
  background: linear-gradient(90deg, #7a5a2c, #c8a45c, #7a5a2c);
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.7;
}

.turn-banner::before {
  left: -90px;
  clip-path: polygon(0 30%, 70% 30%, 100% 50%, 70% 70%, 0 70%);
}

.turn-banner::after {
  right: -90px;
  clip-path: polygon(100% 30%, 30% 30%, 0 50%, 30% 70%, 100% 70%);
}

.turn-crest {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid #c8a45c;
  background: radial-gradient(circle at 30% 30%, #f1e1c2, #7a5a2c 70%);
  position: relative;
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.45);
}

.turn-crest::before,
.turn-crest::after {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(74, 58, 38, 0.6);
  transform: rotate(45deg);
}

.turn-transition.active .turn-crest {
  animation: crestPulse 1.9s ease-in-out both;
}

.turn-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.turn-title {
  font-size: 0.7rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #cbb48a;
  font-family: "Press Start 2P", "Courier New", monospace;
}

.turn-player {
  font-size: 1.4rem;
  font-family: "Press Start 2P", "Courier New", monospace;
  letter-spacing: 1px;
}

.victory-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 60;
  opacity: 0;
  background: radial-gradient(circle, rgba(0, 0, 0, 0.6), transparent 65%);
  transition: opacity 0.3s ease;
}

.victory-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.victory-card {
  padding: 28px 36px;
  border-radius: 10px;
  border: 4px solid #7a5a2c;
  background: linear-gradient(145deg, #f4e3c4, #d3b283);
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.45);
  text-align: center;
  opacity: 0;
  transform: translateY(18px) scale(0.96);
  position: relative;
}

.victory-overlay.active .victory-card {
  animation: victoryRise 2.4s ease-out both;
}

.victory-card::before,
.victory-card::after {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  height: 6px;
  background: linear-gradient(90deg, #7a5a2c, #d8b36a, #7a5a2c);
  opacity: 0.7;
}

.victory-card::before {
  top: 12px;
}

.victory-card::after {
  bottom: 12px;
}

.victory-crown {
  width: 90px;
  height: 46px;
  margin: 0 auto 12px;
  background: linear-gradient(120deg, #f7dd93, #b8892f);
  clip-path: polygon(0 100%, 0 45%, 18% 45%, 30% 0, 42% 45%, 58% 45%, 70% 0, 82% 45%, 100% 45%, 100% 100%);
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.25);
}

.victory-overlay.active .victory-crown {
  animation: crownFlare 2.4s ease-out both;
}

.victory-title {
  font-family: "Press Start 2P", "Courier New", monospace;
  font-size: 1rem;
  letter-spacing: 3px;
  text-transform: uppercase;
  color: #5a3c18;
}

.victory-text {
  margin-top: 10px;
  font-size: 1.2rem;
  color: #2a1a11;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.victory-name {
  font-size: 1.3rem;
  color: #7a4f1c;
  font-family: "Press Start 2P", "Courier New", monospace;
}

.victory-sub {
  margin-top: 12px;
  font-size: 1rem;
  color: #5b4630;
}

.victory-card .btn {
  margin-top: 16px;
}

.rules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 20px;
}


.rules ul {
  margin: 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 0.95rem;
}

.hidden {
  display: none;
}

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

@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.97);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes bannerReveal {
  0% {
    opacity: 0;
    transform: translateY(14px) scale(0.92);
  }
  15% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  70% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
}

@keyframes crestPulse {
  0% {
    transform: scale(0.8) rotate(-8deg);
  }
  35% {
    transform: scale(1) rotate(0deg);
  }
  100% {
    transform: scale(0.92) rotate(6deg);
  }
}

@keyframes diceShuffle {
  0% {
    transform: translateY(0) rotate(0deg);
  }
  50% {
    transform: translateY(-4px) rotate(6deg);
  }
  100% {
    transform: translateY(0) rotate(-5deg);
  }
}

@keyframes victoryRise {
  0% {
    opacity: 0;
    transform: translateY(24px) scale(0.94);
  }
  20% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  75% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 1;
    transform: translateY(-6px) scale(1.02);
  }
}

@keyframes crownFlare {
  0% {
    transform: translateY(6px) scale(0.8);
    filter: brightness(0.9);
  }
  40% {
    transform: translateY(0) scale(1);
    filter: brightness(1.1);
  }
  100% {
    transform: translateY(-2px) scale(1.02);
    filter: brightness(1.05);
  }
}

@keyframes threadSnap {
  0% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-4px);
  }
  100% {
    transform: translateY(0);
  }
}

@keyframes candleFlare {
  0% {
    box-shadow: 0 0 0 rgba(247, 233, 200, 0.2);
  }
  40% {
    box-shadow: 0 0 22px rgba(247, 233, 200, 0.6);
  }
  100% {
    box-shadow: 0 0 0 rgba(247, 233, 200, 0.2);
  }
}

@keyframes ravenCroak {
  0% {
    opacity: 0;
    transform: translateY(6px) scale(0.9);
  }
  30% {
    opacity: 0.8;
  }
  100% {
    opacity: 0;
    transform: translateY(-6px) scale(1.05);
  }
}

@media (prefers-reduced-motion: reduce) {
  .turn-transition.active .turn-banner,
  .turn-transition.active .turn-crest,
  .victory-overlay.active .victory-card,
  .victory-overlay.active .victory-crown,
  .die.rolling,
  .game.farkle-turn .status,
  .game.farkle-turn .dice-area,
  .game.farkle-turn .dice-area::after,
  .game.hot-dice .dice-area {
    animation: none;
  }
}

@media (max-width: 900px) {
  .board {
    grid-template-columns: 1fr;
  }

  .dice-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .selected-info {
    text-align: left;
  }

  .selected-score {
    justify-content: flex-start;
  }

  .die {
    width: 64px;
    height: 64px;
  }
}

@media (max-width: 600px) {
  .screen {
    padding: 44px 14px 48px;
  }

  .panel {
    padding: 18px;
  }

  .controls {
    flex-direction: column;
  }

  .victory-card {
    width: min(90vw, 320px);
    padding: 22px;
  }

  .audio-toggle {
    top: 14px;
    right: 14px;
    width: 40px;
    height: 40px;
  }

  .player-row {
    grid-template-columns: auto 1fr;
  }

  .player-row .btn {
    grid-column: 1 / -1;
    justify-self: end;
  }


  .audio-toggle svg {
    width: 18px;
    height: 18px;
  }

  .player-portrait {
    width: 60px;
    height: 60px;
  }

  .avatar-option img {
    width: 80px;
    height: 80px;
  }
}
