:root {
  color-scheme: dark;
  --background: #0b1017;
  --surface: #121a24;
  --surface-raised: #182330;
  --surface-soft: #202e3d;
  --border: #2a3a4d;
  --text: #f4f7fb;
  --muted: #9cacbe;
  --accent: #61d9a8;
  --accent-strong: #2fcf91;
  --accent-ink: #06291d;
  --warning: #ffcb6b;
  --danger: #ff7d8d;
  --radius: 18px;
  --shadow: 0 22px 60px rgba(0, 0, 0, 0.35);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

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

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 0%, rgba(47, 207, 145, 0.11), transparent 32rem),
    radial-gradient(circle at 95% 10%, rgba(76, 137, 255, 0.08), transparent 28rem),
    var(--background);
}

button,
select,
input {
  font: inherit;
}

button,
a,
select,
input[type="range"] {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(97, 217, 168, 0.55);
  outline-offset: 3px;
}

.site-header,
.game-header,
.mode-grid,
.video-compatibility,
.game-layout,
.site-footer {
  width: min(1180px, calc(100% - 40px));
  margin-inline: auto;
}

.site-header {
  padding-top: clamp(48px, 9vw, 110px);
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 850px;
  margin-bottom: 10px;
  font-size: clamp(32px, 5vw, 58px);
  line-height: 1.05;
  letter-spacing: -0.04em;
}

h2 {
  margin-bottom: 8px;
  font-size: clamp(22px, 3vw, 30px);
  letter-spacing: -0.025em;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
  padding-block: clamp(54px, 8vw, 96px);
}

.mode-card {
  padding: clamp(26px, 4vw, 42px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  background: linear-gradient(145deg, rgba(28, 41, 55, 0.96), rgba(15, 23, 33, 0.96));
  box-shadow: var(--shadow);
  text-decoration: none;
  transition: transform 160ms ease, border-color 160ms ease;
}

.mode-card:hover {
  transform: translateY(-4px);
  border-color: rgba(97, 217, 168, 0.55);
}

.mode-card p {
  max-width: 480px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.65;
}

.video-compatibility {
  margin-bottom: clamp(64px, 8vw, 96px);
  padding: clamp(26px, 4vw, 42px);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(18, 26, 36, 0.82);
  box-shadow: var(--shadow);
}

.compatibility-heading {
  max-width: 850px;
}

.compatibility-heading h2 {
  margin-bottom: 12px;
}

.compatibility-description {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.65;
}

.compatibility-heading strong {
  color: var(--text);
}

.compatibility-table-wrap {
  margin-top: 28px;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 13px;
}

.compatibility-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 13px;
  line-height: 1.5;
}

.compatibility-table th,
.compatibility-table td {
  padding: 15px 17px;
  text-align: left;
  vertical-align: top;
}

.compatibility-table th {
  color: var(--accent);
  background: rgba(97, 217, 168, 0.07);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.compatibility-table th:first-child {
  width: 43%;
}

.compatibility-table th:nth-child(2) {
  width: 32%;
}

.compatibility-table td {
  color: var(--muted);
  border-top: 1px solid var(--border);
}

.compatibility-table td:nth-child(2) {
  color: var(--text);
}

.compatibility-table td::before {
  display: none;
  content: attr(data-label);
}

.compatibility-note {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding-block: 24px 38px;
  border-top: 1px solid rgba(42, 58, 77, 0.72);
  color: var(--muted);
  font-size: 12px;
}

.site-footer small {
  text-align: right;
}

.game-header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: start;
  gap: 24px;
  padding-block: 32px 26px;
}

.game-header h1 {
  margin-bottom: 6px;
  font-size: clamp(26px, 4vw, 42px);
}

.back-link {
  margin-top: 5px;
  padding: 8px 0;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
}

.back-link:hover {
  color: var(--text);
}

.connection-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 5px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--muted);
  background: rgba(18, 26, 36, 0.8);
  font-size: 12px;
  font-weight: 700;
}

.connection-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 0 4px rgba(255, 203, 107, 0.1);
}

.connection-pill[data-state="connected"] .connection-dot {
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(97, 217, 168, 0.12);
}

.connection-pill[data-state="offline"] .connection-dot {
  background: var(--danger);
  box-shadow: 0 0 0 4px rgba(255, 125, 141, 0.12);
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.75fr) minmax(310px, 0.75fr);
  align-items: start;
  gap: 22px;
  padding-bottom: 46px;
}

.player-panel,
.bet-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(18, 26, 36, 0.93);
  box-shadow: var(--shadow);
}

.player-panel {
  overflow: hidden;
}

.bet-panel {
  padding: 24px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.player-panel > .panel-heading {
  padding: 23px 24px 17px;
}

.panel-heading h2 {
  margin-bottom: 0;
  font-size: 24px;
}

.round-id,
.countdown {
  flex: 0 0 auto;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.countdown {
  min-width: 58px;
  color: var(--accent);
  font-size: 22px;
  font-weight: 800;
  text-align: right;
}

.video-shell {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #030506;
}

.video-shell video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #030506;
}

.video-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
  padding: 24px;
  color: var(--text);
  background: linear-gradient(rgba(5, 9, 13, 0.72), rgba(5, 9, 13, 0.82));
  text-align: center;
  transition: opacity 180ms ease;
}

.video-overlay[data-passive="true"] {
  pointer-events: none;
  opacity: 0;
}

.video-overlay strong {
  font-size: clamp(18px, 3vw, 25px);
}

.video-overlay span {
  max-width: 520px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.video-overlay .overlay-countdown {
  margin-block: 2px 5px;
  color: var(--text);
  font-size: clamp(64px, 11vw, 104px);
  font-weight: 850;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.06em;
  line-height: 0.95;
}

.video-readiness {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 3px;
  padding: 8px 12px;
  border: 1px solid rgba(255, 203, 107, 0.28);
  border-radius: 999px;
  color: var(--warning);
  background: rgba(255, 203, 107, 0.08);
  font-size: 12px;
  font-weight: 750;
}

.video-readiness[data-ready="true"] {
  border-color: rgba(97, 217, 168, 0.36);
  color: var(--accent);
  background: rgba(97, 217, 168, 0.09);
}

.video-readiness .readiness-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.video-readiness #video-readiness-label {
  color: currentColor;
  font-size: inherit;
  line-height: 1.2;
}

.overlay-spinner {
  width: 28px;
  height: 28px;
  margin-bottom: 8px;
  border: 3px solid rgba(255, 255, 255, 0.14);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}

.overlay-spinner[data-active="false"] {
  display: none;
}

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

.player-controls {
  display: grid;
  grid-template-columns: auto minmax(160px, 1fr) minmax(145px, auto) auto;
  align-items: end;
  gap: 14px;
  padding: 17px 20px 12px;
  border-top: 1px solid var(--border);
}

.control-button,
.primary-button,
.secondary-button,
.puppy-button,
select {
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 11px;
  color: var(--text);
  background: var(--surface-raised);
  cursor: pointer;
}

.control-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 13px;
  font-size: 13px;
  font-weight: 700;
}

.control-button:hover,
.secondary-button:hover,
select:hover {
  border-color: #486079;
  background: var(--surface-soft);
}

.control-group {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.control-group input,
.control-group select {
  width: 100%;
}

input[type="range"] {
  accent-color: var(--accent-strong);
}

select {
  height: 44px;
  padding: 0 34px 0 12px;
  font-size: 13px;
  font-weight: 700;
}

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

.control-help {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  padding: 0 20px 18px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.puppy-grid {
  display: grid;
  margin-top: 18px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.puppy-button {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 52px;
  padding: 8px 10px;
  font-size: 13px;
  font-weight: 700;
}

.puppy-button span {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border-radius: 9px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.055);
}

.puppy-button:hover:not(:disabled) {
  border-color: #486079;
  background: var(--surface-soft);
}

.puppy-button[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(97, 217, 168, 0.1);
}

.puppy-button[aria-pressed="true"] span {
  color: var(--accent-ink);
  background: var(--accent);
}

.primary-button,
.secondary-button {
  padding: 11px 17px;
  font-weight: 800;
}

.primary-button {
  border-color: var(--accent);
  color: var(--accent-ink);
  background: var(--accent);
}

.primary-button:hover:not(:disabled) {
  border-color: #82e7bd;
  background: #82e7bd;
}

.bet-panel > .primary-button {
  width: 100%;
  margin-top: 14px;
}

.secondary-button {
  color: var(--text);
  background: var(--surface-raised);
}

.video-overlay .secondary-button {
  margin-top: 10px;
  pointer-events: auto;
}

.result-card {
  margin-top: 16px;
  padding: 17px;
  border: 1px solid rgba(97, 217, 168, 0.33);
  border-radius: 12px;
  background: rgba(97, 217, 168, 0.07);
}

.podium {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.podium span {
  flex: 1;
  padding: 8px;
  border-radius: 8px;
  color: var(--accent-ink);
  background: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-align: center;
}

.result-card > strong {
  font-size: 13px;
  line-height: 1.45;
}

.sound-prompt {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(3, 6, 9, 0.84);
  backdrop-filter: blur(8px);
}

.sound-card {
  width: min(460px, 100%);
  padding: clamp(26px, 6vw, 42px);
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}

.sound-card h2 {
  font-size: 28px;
}

.sound-card > p:not(.eyebrow) {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.6;
}

.sound-icon {
  display: grid;
  width: 58px;
  height: 58px;
  margin: 0 auto 22px;
  place-items: center;
  border-radius: 17px;
  color: var(--accent);
  background: rgba(97, 217, 168, 0.1);
  font-size: 28px;
}

.sound-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 24px;
}

@media (max-width: 880px) {
  .game-header {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .connection-pill {
    grid-column: 2;
    justify-self: start;
    margin-top: 0;
  }

  .game-layout {
    grid-template-columns: 1fr;
  }

  .bet-panel {
    grid-row: 1;
  }
}

@media (max-width: 680px) {
  .site-header,
  .game-header,
  .mode-grid,
  .video-compatibility,
  .game-layout,
  .site-footer {
    width: min(100% - 24px, 1180px);
  }

  .site-header {
    padding-top: 42px;
  }

  .mode-grid {
    grid-template-columns: 1fr;
    padding-block: 40px 64px;
  }

  .video-compatibility {
    padding: 22px;
  }

  .compatibility-table-wrap {
    overflow: visible;
    border: 0;
  }

  .compatibility-table,
  .compatibility-table tbody,
  .compatibility-table tr,
  .compatibility-table td {
    display: block;
    width: 100%;
  }

  .compatibility-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .compatibility-table tr {
    margin-top: 10px;
    padding: 12px 14px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: rgba(5, 9, 13, 0.25);
  }

  .compatibility-table td {
    display: grid;
    grid-template-columns: minmax(105px, 0.42fr) 1fr;
    gap: 12px;
    padding: 6px 0;
    border: 0;
  }

  .compatibility-table td::before {
    display: block;
    color: var(--accent);
    font-size: 10px;
    font-weight: 750;
    letter-spacing: 0.06em;
    text-transform: uppercase;
  }

  .site-footer {
    flex-direction: column;
    gap: 8px;
  }

  .site-footer small {
    text-align: left;
  }

  .game-header {
    grid-template-columns: 1fr auto;
    gap: 12px;
    padding-top: 20px;
  }

  .game-title {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .connection-pill {
    grid-column: 2;
    grid-row: 1;
  }

  .player-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .control-help {
    grid-template-columns: 1fr;
  }

  .sound-actions {
    grid-template-columns: 1fr;
  }
}

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

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

  .control-button,
  .control-group {
    width: 100%;
  }
}

@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;
  }
}
