:root {
  color-scheme: dark;
  --bg: #0f1419;
  --bg-card: #1a2332;
  --bg-elevated: #243044;
  --text: #e8eef7;
  --muted: #8b9bb4;
  --accent: #f0c14b;
  --accent-dim: #c99f2f;
  --danger: #e85d5d;
  --success: #3ecf8e;
  --warning: #f0a030;
  --radius: 16px;
  --app-max: 480px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.hidden {
  display: none !important;
}

.app {
  max-width: var(--app-max);
  margin: 0 auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.brand {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 0.4rem;
}

.brand h1 {
  justify-self: start;
  font-size: 1.35rem;
  margin: 0;
  letter-spacing: 0.04em;
  color: var(--accent);
}

.brand .sound-control {
  justify-self: center;
  width: min(9.5rem, 36vw);
}

.brand-trailing {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-width: 0;
}

.brand-code {
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--text);
}

.brand #conn-status {
  display: none;
}

.home-nav {
  display: flex;
  gap: 0.75rem;
  margin-top: -0.4rem;
}

.home-nav a {
  color: var(--muted);
  font-size: 0.85rem;
  text-decoration: none;
}

.home-nav a:hover {
  color: var(--accent);
}

body.play-active .home-nav,
body.play-active #home,
body.play-active #room {
  display: none !important;
}

body.play-active {
  --app-max: 480px;
  --play-actions-h: 12.5rem;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

body.play-active .games-platform-bar {
  flex: 0 0 auto;
}

body.play-active .brand {
  flex: 0 0 auto;
  padding: 0.35rem 0.75rem 0.15rem;
}

body.play-active .app {
  flex: 1 1 auto;
  min-height: 0;
  max-width: var(--app-max);
  padding: 0;
  gap: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#screen-play:not(.hidden) {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  width: 100%;
  max-width: var(--app-max);
  margin: 0 auto;
  min-height: 0;
  overflow: hidden;
}

#screen-play .play-scroll {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0.45rem 0.85rem 0.15rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#screen-play .scorecard-scroll {
  flex: 1 1 auto;
  min-height: 6rem;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0.35rem 0 0;
}

#screen-play .play-actions {
  position: sticky;
  left: auto;
  bottom: 0;
  transform: none;
  width: 100%;
  max-width: none;
  overflow: hidden;
}

#screen-play .play-dice-dock {
  flex: 0 0 auto;
  padding: 0.15rem 0 0.35rem;
  overflow: hidden;
}

#screen-play .dice-row {
  overflow: hidden;
}

#screen-play .play-dice-dock .dice-row {
  margin: 0;
}

#screen-play .play-dice-dock .rolls-remaining {
  display: block;
  text-align: center;
  margin: 0.25rem 0 0;
}

.conn-status {
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  background: var(--bg-elevated);
  color: var(--muted);
}

.conn-status.live {
  color: var(--success);
}

.conn-status.down {
  color: var(--warning);
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.card h2 {
  margin: 0;
  font-size: 1rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.field-inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}

input,
select {
  background: var(--bg-elevated);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 0.55rem 0.7rem;
  color: var(--text);
  font-size: 0.9rem;
}

.row {
  display: flex;
  gap: 0.5rem;
}

.row input {
  flex: 1;
}

.play-tools-row {
  display: flex;
  align-items: stretch;
  gap: 0.4rem;
  margin-bottom: 0.6rem;
}

.play-tools-row .btn-secondary {
  width: auto;
  flex: 1 1 0;
  min-width: 0;
  margin-top: 0;
}

button {
  border: none;
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-dim));
  color: #17140a;
  font-weight: 600;
}

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.room-code-box {
  background: var(--bg-elevated);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
}

.room-code-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.room-code-label {
  color: var(--muted);
  font-size: 0.75rem;
  margin-right: 0.4rem;
}

.room-code {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.player-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.player-row {
  background: var(--bg-elevated);
  border-radius: 10px;
  padding: 0.5rem 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.9rem;
}

.player-row.is-turn {
  outline: 2px solid var(--success);
}

.player-dot {
  display: inline-block;
  width: 0.6rem;
  height: 0.6rem;
  border-radius: 50%;
  margin-right: 0.4rem;
}

.badge {
  font-size: 0.7rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  margin-left: 0.4rem;
}

.badge.host {
  color: var(--accent);
}

.badge.ready {
  color: var(--success);
}

.lobby-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.lobby-actions button {
  flex: 1;
}

.status-line {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.dice-row {
  display: flex;
  gap: 0.65rem;
  justify-content: center;
  min-height: 56px;
}

/* Same dice as Bank: white rounded square, dark bold numeral, soft shadow */
.die {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  background: #f5f5f5;
  color: #1a1a1a;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.45rem;
  font-weight: 800;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  user-select: none;
}

.die.is-held {
  box-shadow:
    0 0 0 3px var(--accent),
    0 4px 12px rgba(0, 0, 0, 0.3);
  background: #fff6dd;
}

.die:disabled {
  cursor: default;
}

.die.is-disabled {
  cursor: default;
  opacity: 0.6;
}

.die.rolling {
  animation: dice-roll 0.12s linear infinite;
  box-shadow: 0 0 16px rgba(61, 156, 240, 0.45);
}

.die.settle {
  animation: dice-settle 0.4s ease;
}

@keyframes dice-roll {
  0% {
    transform: rotate(-18deg) scale(1.08);
  }
  50% {
    transform: rotate(18deg) scale(0.96);
  }
  100% {
    transform: rotate(-18deg) scale(1.08);
  }
}

@keyframes dice-settle {
  0% {
    transform: scale(1.2) rotate(-8deg);
  }
  50% {
    transform: scale(0.95) rotate(4deg);
  }
  100% {
    transform: scale(1) rotate(0);
  }
}

.roll-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.rolls-remaining {
  color: var(--muted);
  font-size: 0.85rem;
}

.scorecard-scroll {
  overflow-x: auto;
}

.scorecard {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 0.74rem;
}

.scorecard th,
.scorecard td {
  padding: 0.18rem 0.28rem;
  text-align: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  white-space: nowrap;
}

.scorecard th:first-child,
.scorecard td:first-child {
  width: auto;
  text-align: left;
  color: var(--muted);
}

.scorecard tr.is-section-total td {
  color: var(--muted);
  font-style: italic;
}

.score-cell {
  width: 18%;
  min-width: 0;
}

.score-cell.is-open {
  color: var(--muted);
}

.score-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 100%;
  height: 1.35rem;
  min-height: 1.35rem;
  padding: 0;
  font-size: 0.68rem;
  font-weight: 700;
  line-height: 1;
}

.score-cell button.score-slot {
  background: rgba(139, 90, 43, 0.16);
  color: #5a3a18;
  border-radius: 4px;
  border: 1px solid rgba(90, 58, 24, 0.25);
}

.paper-scorecard {
  background:
    radial-gradient(ellipse 80% 50% at 10% 0%, rgba(255, 236, 179, 0.55), transparent 55%),
    linear-gradient(180deg, #f6e6c2 0%, #edd6a4 55%, #e4c78d 100%);
  color: #3a2a14;
  border: 1px solid rgba(90, 58, 24, 0.28);
  border-radius: 8px;
  box-shadow:
    inset 0 0 0 1px rgba(255, 248, 230, 0.55),
    0 8px 18px rgba(40, 24, 8, 0.18);
  padding: 0.35rem 0.4rem;
}

.paper-scorecard .scorecard {
  color: #3a2a14;
}

.paper-scorecard .scorecard th,
.paper-scorecard .scorecard td {
  border-bottom: 1px solid rgba(90, 58, 24, 0.18);
  color: #3a2a14;
}

.paper-scorecard .scorecard th:first-child,
.paper-scorecard .scorecard td:first-child {
  color: #5a3a18;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  font-size: 0.68rem;
}

.paper-scorecard .scorecard thead th {
  background: rgba(139, 90, 43, 0.16);
  font-size: 0.72rem;
}

.paper-scorecard .is-section-total th,
.paper-scorecard .is-section-total td {
  background: rgba(139, 90, 43, 0.12);
  font-weight: 800;
  font-style: normal;
}

.paper-scorecard .is-grand-total th,
.paper-scorecard .is-grand-total td {
  background: rgba(90, 58, 24, 0.2);
  font-weight: 900;
}

.paper-scorecard .score-cell.is-open {
  color: rgba(90, 58, 24, 0.45);
}

/* .toast comes from platform-shell/shell-base.css */

.mini-action {
  min-height: 1.75rem;
  margin-right: 0.35rem;
  padding: 0.2rem 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: var(--bg-elevated);
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: 8px;
}

.vote-kick-banner {
  margin-bottom: 0.5rem;
  padding: 0.65rem 0.75rem;
  border: 1px solid rgba(232, 93, 93, 0.4);
  border-radius: 10px;
  background: rgba(232, 93, 93, 0.1);
  font-size: 0.85rem;
}

.vote-kick-banner p {
  margin: 0 0 0.4rem;
}

.vote-kick-banner .row {
  gap: 0.5rem;
}

.turn-idle-announce {
  position: fixed;
  inset: auto 1rem 4rem auto;
  z-index: 60;
  max-width: min(18rem, calc(100% - 2rem));
  opacity: 0;
  pointer-events: none;
  transform: translateY(0.75rem);
  transition: opacity 160ms ease, transform 160ms ease;
}

.turn-idle-announce.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.turn-idle-announce-card {
  padding: 0.7rem 0.85rem;
  border: 1px solid rgba(62, 207, 142, 0.45);
  border-radius: 10px;
  background: #102018;
  color: var(--text);
  box-shadow: 0 0.8rem 2rem rgba(0, 0, 0, 0.35);
}

.turn-idle-announce-kicker,
.turn-idle-announce-title {
  margin: 0;
}

.turn-idle-announce-kicker {
  color: var(--success);
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
}

.turn-idle-announce-title {
  margin-top: 0.25rem;
  font-weight: 600;
}

.play-avatars {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.45rem;
  overflow-x: auto;
  padding: 0.15rem 0 0.35rem;
}

.play-avatar {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  min-width: 2.6rem;
  padding: 0.2rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.1;
}

.play-avatar-dot {
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 800;
  color: #0f1419;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.08);
}

.play-avatar.is-turn .play-avatar-dot {
  box-shadow: 0 0 0 2px var(--success);
}

.play-avatar-name {
  max-width: 3.4rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.play-avatar.is-turn .play-avatar-name {
  color: var(--text);
  font-weight: 700;
}

.play-avatar-score {
  font-size: 0.72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.play-avatar.is-away {
  opacity: 0.5;
}

.play-avatar .mini-action {
  padding: 0 0.3rem;
  font-size: 0.65rem;
}

.result-panel {
  margin: 0.35rem 0;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  background: var(--bg-elevated);
}

.result-panel h2 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
}

.game-start-announce {
  position: fixed;
  inset: 0;
  z-index: 180;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  background: rgba(8, 12, 18, 0.72);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.game-start-announce.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.game-start-announce-card {
  text-align: center;
  max-width: min(92vw, 22rem);
  padding: 1.75rem 1.5rem 1.5rem;
  border-radius: 20px;
  background: linear-gradient(165deg, #1c2838 0%, #121a24 100%);
  border: 1px solid rgba(240, 193, 75, 0.35);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  transform: scale(0.92);
  transition: transform 0.28s ease;
}

.game-start-announce.is-visible .game-start-announce-card {
  transform: scale(1);
}

.game-start-announce-message {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
  margin-bottom: 1rem;
}

.game-start-announce-caption {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--bank-gold);
  margin-bottom: 0.35rem;
}

.game-start-announce-count {
  font-size: 4rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: var(--bank-gold);
  text-shadow: 0 0 28px rgba(240, 193, 75, 0.35);
}

.turn-announce {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  padding-bottom: calc(var(--play-actions-h, 12.5rem) + 0.5rem);
  background: rgba(6, 22, 16, 0.78);
  backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.4s ease, visibility 0.4s ease;
}

.turn-announce.is-visible {
  opacity: 1;
  visibility: visible;
}

.turn-announce.is-fading {
  opacity: 0;
}

.turn-announce-card {
  text-align: center;
  max-width: min(92vw, 22rem);
  width: 100%;
  padding: 1.75rem 1.5rem 1.5rem;
  border-radius: 24px;
  background:
    radial-gradient(ellipse 90% 70% at 50% 0%, rgba(62, 207, 142, 0.4), transparent 60%),
    linear-gradient(165deg, #0f3d2a 0%, #122820 55%, #0a1812 100%);
  border: 2px solid rgba(62, 207, 142, 0.7);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.06) inset,
    0 20px 60px rgba(0, 0, 0, 0.55),
    0 0 48px rgba(62, 207, 142, 0.3);
  transform: scale(0.86) translateY(12px);
  transition: transform 0.4s cubic-bezier(0.22, 1.2, 0.36, 1);
}

.turn-announce.is-visible .turn-announce-card {
  transform: scale(1) translateY(0);
  animation: yahtzee-turn-pulse 0.9s ease 0.12s both;
}

.turn-announce-kicker {
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.28em;
  color: #6eecc0;
  text-shadow: 0 0 18px rgba(62, 207, 142, 0.55);
  margin-bottom: 0.55rem;
}

.turn-announce-title {
  font-size: clamp(1.6rem, 6vw, 2.2rem);
  font-weight: 900;
  color: #fff;
  line-height: 1.15;
  text-shadow: 0 0 24px rgba(62, 207, 142, 0.4);
}

.turn-announce-sub {
  margin-top: 0.65rem;
  font-size: 0.95rem;
  color: #9ed4bc;
}

@keyframes yahtzee-turn-pulse {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}
