﻿:root {
  --bg: #07090d;
  --bg-2: #0d1219;
  --line: #2a303a;
  --line-2: #3a414d;
  --text: #dce2ea;
  --muted: #8f99a8;
  --accent: #95a2b6;
  --accent-2: #e5ebf3;
  --warn: #9a2020;
  --diamond: #bb2a2a;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(circle at 14% 12%, rgba(187, 42, 42, 0.12) 0%, transparent 26%),
    radial-gradient(circle at 86% 9%, rgba(187, 42, 42, 0.08) 0%, transparent 22%),
    linear-gradient(180deg, #0a0d13, #05070b 55%, #04060a),
    var(--bg);
  color: var(--text);
  font-family: "IBM Plex Mono", "Courier New", monospace;
}

.scene {
  position: relative;
  width: 100%;
  height: 100dvh;
  padding: 2.2vh 2.6vw;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 1.5vh;
  overflow: hidden;
}

.scene::before,
.scene::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.scene::before {
  background:
    linear-gradient(
      135deg,
      transparent 43%,
      rgba(187, 42, 42, 0.06) 49%,
      rgba(255, 255, 255, 0.05) 50%,
      rgba(187, 42, 42, 0.06) 51%,
      transparent 57%
    ),
    linear-gradient(
      315deg,
      transparent 44%,
      rgba(187, 42, 42, 0.05) 49%,
      rgba(255, 255, 255, 0.04) 50%,
      rgba(187, 42, 42, 0.05) 51%,
      transparent 56%
    ),
    linear-gradient(135deg, transparent 45%, rgba(255, 255, 255, 0.02) 50%, transparent 55%),
    repeating-linear-gradient(
      to bottom,
      transparent 0px,
      transparent 2px,
      rgba(255, 255, 255, 0.02) 3px,
      transparent 4px
    );
  background-size: 140% 140%, 150% 150%, auto, auto;
  background-position: 50% 50%, 50% 50%, 0 0, 0 0;
  opacity: 0.45;
  z-index: 0;
  animation: diamond-shine 18s ease-in-out infinite alternate;
}

.scene::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1200' height='700' viewBox='0 0 1200 700'%3E%3Crect x='10' y='10' width='1180' height='680' fill='none' stroke='rgba(187,42,42,0.14)' stroke-width='1'/%3E%3Ctext x='80' y='120' fill='rgba(187,42,42,0.14)' font-size='92' font-family='Courier New'%3EK%3C/text%3E%3Ctext x='74' y='192' fill='rgba(187,42,42,0.14)' font-size='70' font-family='Courier New'%3E%E2%99%A6%3C/text%3E%3Ctext x='1120' y='640' fill='rgba(187,42,42,0.14)' font-size='92' font-family='Courier New' text-anchor='end'%3EK%3C/text%3E%3Ctext x='1126' y='568' fill='rgba(187,42,42,0.14)' font-size='70' font-family='Courier New' text-anchor='end'%3E%E2%99%A6%3C/text%3E%3Ctext x='600' y='380' fill='rgba(187,42,42,0.08)' font-size='220' font-family='Courier New' text-anchor='middle'%3E%E2%99%A6%3C/text%3E%3C/svg%3E");
  background-size: 106% 106%;
  background-position: center;
  opacity: 0.52;
  z-index: 0;
  animation: king-drift 30s ease-in-out infinite, king-pulse 9s ease-in-out infinite;
}

.topbar,
.players-panel,
.choice-zone,
.system-strip {
  position: relative;
  z-index: 1;
  transition: opacity 520ms ease, transform 520ms ease, filter 520ms ease;
}

.scene.round-smooth .choice-zone,
.scene.round-smooth .players-panel,
.scene.round-smooth .system-strip {
  opacity: 0.4;
  transform: translateY(7px);
  filter: blur(0.35px);
}

.scene.round-smooth .selected-number {
  transform: translateY(3px) scale(0.985);
  opacity: 0.6;
  transition: transform 520ms ease, opacity 520ms ease;
}

.bg-chant {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  opacity: 1;
}

.bg-chant p {
  display: none;
}

.bg-chant::before,
.bg-chant::after {
  display: none;
}

.matrix-bg-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0.3;
  filter: blur(0.12px);
  mix-blend-mode: screen;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.15rem, 2.2vw, 2rem);
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--accent-2);
  border-bottom: 1px solid var(--line);
  padding-bottom: 0.45rem;
  text-shadow: 0 0 10px rgba(154, 32, 32, 0.2);
}

.session-strip {
  display: flex;
  gap: 0.8rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 0.4rem;
  padding-right: 150px;
  color: #a8b1c0;
  font-size: clamp(0.62rem, 0.85vw, 0.78rem);
}

.volume-control {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: #aab4c3;
}

.volume-control label {
  font-size: clamp(0.56rem, 0.75vw, 0.68rem);
  letter-spacing: 0.08em;
}

.volume-control input[type="range"] {
  width: 92px;
  accent-color: #95a2b6;
  cursor: pointer;
}

.volume-control span {
  min-width: 34px;
  font-size: clamp(0.56rem, 0.75vw, 0.68rem);
  color: #d3dbe8;
}

.minimal-btn {
  border: 1px solid #434b56;
  background: rgba(255, 255, 255, 0.02);
  color: #d5deeb;
  font: inherit;
  font-size: clamp(0.6rem, 0.82vw, 0.76rem);
  letter-spacing: 0.08em;
  padding: 0.24rem 0.5rem;
  cursor: pointer;
}

.minimal-btn:hover {
  border-color: #617189;
  color: #ecf2fb;
}

.minimal-btn.start {
  border-color: rgba(187, 42, 42, 0.65);
  color: #f2d7d7;
  background: rgba(187, 42, 42, 0.1);
}

.minimal-btn.start:hover {
  border-color: rgba(187, 42, 42, 0.9);
  color: #ffe6e6;
  background: rgba(187, 42, 42, 0.18);
}

.minimal-btn.danger {
  border-color: rgba(154, 32, 32, 0.7);
  color: #f1cfd0;
  background: rgba(154, 32, 32, 0.12);
}

.minimal-btn.danger:hover {
  border-color: rgba(197, 54, 54, 0.95);
  color: #ffe7e7;
  background: rgba(154, 32, 32, 0.2);
}

.minimal-btn.logout-corner {
  position: absolute;
  top: 0.15rem;
  right: 0;
  border: none;
  background: transparent;
}

.minimal-btn.logout-corner:hover,
.minimal-btn.logout-corner:focus-visible {
  border: none;
  background: rgba(255, 255, 255, 0.04);
}

.minimal-btn.full {
  width: 100%;
  margin-top: 0.6rem;
}

.hidden {
  display: none !important;
}

.choice-zone {
  grid-row: 3;
  align-self: center;
  justify-self: center;
  width: min(95vw, 980px);
  display: grid;
  justify-items: center;
  gap: 0.75vh;
}

.controls-hint {
  margin: 0;
  font-size: clamp(0.75rem, 1vw, 0.9rem);
  color: #a8b1c0;
  letter-spacing: 0.04em;
}

.selected-number {
  margin: 0;
  min-height: 1.2em;
  font-size: clamp(2.6rem, 7.4vw, 5.3rem);
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--accent-2);
  text-shadow: 0 0 14px rgba(187, 42, 42, 0.24);
}

.number-grid {
  position: relative;
  z-index: 2;
  width: min(95vw, 920px);
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: 6px;
  padding: 8px;
  border: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.055), rgba(0, 0, 0, 0.42)),
    linear-gradient(45deg, transparent 48%, rgba(255, 255, 255, 0.05) 50%, transparent 52%),
    rgba(6, 10, 16, 0.72);
}

.grid-cell {
  min-height: clamp(28px, 4vh, 36px);
  display: grid;
  place-items: center;
  border: none;
  border-radius: 6px;
  background: rgba(10, 14, 20, 0.66);
  color: #aeb8c8;
  font-size: clamp(0.72rem, 0.96vw, 0.92rem);
  user-select: none;
  cursor: pointer;
  transition: color 120ms linear, background 120ms linear;
}

.grid-cell:hover {
  background: rgba(18, 24, 34, 0.82);
  color: #e4eaf2;
}

.grid-cell.selected {
  color: #e8eef8;
  background: rgba(187, 42, 42, 0.2);
}

.grid-cell.locked {
  color: #c8d1df;
  cursor: default;
  background: rgba(25, 31, 42, 0.78);
}

.grid-cell.disabled {
  opacity: 0.4;
  pointer-events: none;
}

.players-panel {
  grid-row: 2;
  position: static;
  width: 100%;
  padding: 0;
  border: none;
  box-shadow: none;
  background: transparent;
}

.players-panel h2 {
  margin: 0 0 0.25rem;
  font-size: clamp(0.84rem, 1.06vw, 0.96rem);
  color: #acb5c4;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.players-panel ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.players-panel li {
  margin: 0;
  border: none;
  background: transparent;
  min-height: 68px;
}

.players-panel li.you {
  border: none;
  background: transparent;
}

.players-panel li.winner {
  border: none;
}

.players-panel li.eliminated {
  border: none;
  background: transparent;
}

.card-wrap {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 6px;
  align-items: center;
  padding: 0.25rem 0.28rem;
}

.player-avatar {
  width: 44px;
  height: 44px;
  border: none;
  background-color: #1c2330;
  background-size: cover;
  background-position: center;
  display: grid;
  place-items: center;
  color: #dce4f0;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  box-shadow: none;
}

.players-panel li.eliminated .player-avatar {
  filter: grayscale(1);
  opacity: 0.65;
}

.card-meta {
  min-width: 0;
  display: grid;
  gap: 1px;
}

.card-top {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.card-top .name {
  flex: 1;
  font-size: clamp(0.6rem, 0.74vw, 0.72rem);
  color: #d8e2f1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-top .type,
.card-top .status {
  font-size: clamp(0.52rem, 0.66vw, 0.6rem);
  color: #9ea9bc;
  white-space: nowrap;
}

.card-mid {
  font-size: clamp(0.54rem, 0.7vw, 0.62rem);
  color: #b7c2d3;
}

.hearts {
  display: flex;
  flex-wrap: wrap;
  gap: 1px 2px;
  line-height: 1;
}

.heart {
  font-size: 0.5rem;
}

.heart.active {
  color: var(--diamond);
}

.heart.lost {
  color: #586375;
}

.system-strip {
  display: grid;
  gap: 0;
  border-top: 1px solid var(--line);
  padding-top: 0.45rem;
  background: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.18));
}

#message {
  margin: 0;
  font-size: clamp(0.88rem, 1.22vw, 1.12rem);
  color: #dbe3f0;
}

.reveal-screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 0.5rem;
  background: rgba(7, 8, 12, 0.985);
  backdrop-filter: blur(1.5px);
  border: none;
}

.reveal-screen.hidden {
  display: none;
}

#revealLine1,
#revealLine2 {
  margin: 0;
  font-size: clamp(1rem, 2vw, 1.6rem);
  color: #aab3c0;
}

#revealCount {
  min-height: 1em;
  margin-top: 0.2rem;
  font-size: clamp(3.5rem, 12vw, 8rem);
  color: #e5edf8;
  text-shadow: 0 0 18px rgba(187, 42, 42, 0.25);
}

.reveal-cards {
  width: min(92vw, 1080px);
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.reveal-card {
  border: none;
  background: rgba(11, 15, 22, 0.84);
  padding: 0.42rem 0.5rem;
  min-height: 106px;
  opacity: 0.25;
  transform: translateY(10px) scale(0.97);
  transition: opacity 260ms ease, transform 340ms cubic-bezier(0.2, 0.74, 0.24, 1), background 260ms ease;
}

.reveal-card.shown {
  opacity: 1;
  transform: translateY(0) scale(1);
  background: rgba(14, 20, 30, 0.9);
}

.reveal-card.winner {
  background: rgba(42, 17, 20, 0.9);
}

.reveal-card .top {
  display: flex;
  justify-content: space-between;
  gap: 0.4rem;
  font-size: 0.7rem;
  color: #bcc8db;
}

.reveal-head {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 0.42rem;
  align-items: center;
}

.reveal-avatar {
  width: 34px;
  height: 34px;
  background-color: #1b2230;
  background-size: cover;
  background-position: center;
  border: none;
}

.reveal-identity {
  min-width: 0;
}

.reveal-card .bid {
  margin-top: 0.3rem;
  font-size: clamp(1.2rem, 2vw, 1.8rem);
  color: #e8eef8;
}

.reveal-card .meta {
  margin-top: 0.06rem;
  font-size: 0.64rem;
  color: #9daac0;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 35%, rgba(187, 42, 42, 0.18) 0%, transparent 40%),
    radial-gradient(circle at 12% 88%, rgba(229, 235, 243, 0.06) 0%, transparent 30%),
    rgba(5, 7, 11, 0.95);
}

.login-box {
  position: relative;
  --cut: 18px;
  width: min(92vw, 520px);
  border: none;
  padding: 1rem 1rem 0.9rem;
  background:
    linear-gradient(180deg, rgba(11, 15, 22, 0.95), rgba(7, 10, 15, 0.96)),
    linear-gradient(45deg, transparent 48%, rgba(187, 42, 42, 0.06) 50%, transparent 52%);
  box-shadow: inset 0 0 0 1px rgba(229, 235, 243, 0.06), 0 18px 55px rgba(0, 0, 0, 0.45);
  clip-path: polygon(
    var(--cut) 0,
    100% 0,
    100% calc(100% - var(--cut)),
    calc(100% - var(--cut)) 100%,
    0 100%,
    0 var(--cut)
  );
}

.login-box::before,
.login-box::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.login-box::before {
  inset: 0;
  clip-path: inherit;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0px,
    transparent 2px,
    rgba(255, 255, 255, 0.02) 3px,
    transparent 4px
  );
  opacity: 0.5;
}

.login-box::after {
  inset: 0;
  clip-path: inherit;
  border: 1px solid rgba(96, 109, 128, 0.75);
  box-shadow: inset 0 0 0 10px rgba(7, 10, 15, 0), inset 0 0 0 11px rgba(187, 42, 42, 0.22);
}

.login-kicker {
  position: relative;
  z-index: 1;
  margin: 0 0 0.4rem;
  font-size: 0.66rem;
  letter-spacing: 0.2em;
  color: #aeb9ca;
}

.login-box h2 {
  position: relative;
  z-index: 1;
  margin: 0;
  font-size: clamp(1.06rem, 1.7vw, 1.42rem);
  color: #edf2fb;
  letter-spacing: 0.05em;
}

.login-sub {
  position: relative;
  z-index: 1;
  margin: 0.5rem 0 0.8rem;
  font-size: 0.8rem;
  color: #b8c2d1;
}

.login-divider {
  position: relative;
  z-index: 1;
  margin: 0 0 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: rgba(187, 42, 42, 0.75);
}

.login-divider::before,
.login-divider::after {
  content: "";
  height: 1px;
  background: rgba(154, 32, 32, 0.45);
  flex: 1;
}

.login-divider span {
  font-size: 0.74rem;
  letter-spacing: 0.12em;
}

.login-box form {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 0.38rem;
}

.login-box label {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: #a7b1c1;
}

.login-box input {
  border: 1px solid #3e4758;
  background: rgba(5, 8, 12, 0.9);
  color: #e3eaf6;
  font: inherit;
  font-size: 0.85rem;
  padding: 0.44rem 0.58rem;
  outline: none;
}

.login-box input:focus {
  border-color: #778ca8;
  box-shadow: inset 0 0 0 1px rgba(187, 42, 42, 0.26);
}

.login-message {
  position: relative;
  z-index: 1;
  margin: 0.75rem 0 0;
  min-height: 1.2em;
  font-size: 0.72rem;
  color: #d5deeb;
  letter-spacing: 0.04em;
  border-top: 1px solid rgba(69, 78, 94, 0.58);
  padding-top: 0.55rem;
}

@keyframes chant-flicker {
  0%, 93%, 100% {
    opacity: 0.9;
    filter: blur(0);
  }
  94% {
    opacity: 0.35;
    filter: blur(0.45px);
  }
  96% {
    opacity: 0.78;
    filter: blur(0);
  }
}

@keyframes king-drift {
  0% {
    transform: translate3d(0, 0, 0) scale(1);
  }
  25% {
    transform: translate3d(-0.4%, 0.35%, 0) scale(1.006);
  }
  50% {
    transform: translate3d(0.3%, -0.25%, 0) scale(1.01);
  }
  75% {
    transform: translate3d(-0.2%, -0.35%, 0) scale(1.004);
  }
  100% {
    transform: translate3d(0.35%, 0.2%, 0) scale(1.008);
  }
}

@keyframes king-pulse {
  0%, 100% {
    opacity: 0.46;
    filter: saturate(1) brightness(1);
  }
  50% {
    opacity: 0.62;
    filter: saturate(1.12) brightness(1.08);
  }
}

@keyframes diamond-shine {
  0% {
    background-position: 45% 55%, 58% 40%, 0 0, 0 0;
    opacity: 0.34;
  }
  50% {
    background-position: 52% 48%, 48% 52%, 0 0, 0 0;
    opacity: 0.5;
  }
  100% {
    background-position: 58% 44%, 40% 58%, 0 0, 0 0;
    opacity: 0.38;
  }
}

@media (max-width: 980px) {
  .choice-zone {
    width: 96vw;
    gap: 0.55vh;
  }

  .number-grid {
    width: 96vw;
    gap: 4px;
    padding: 6px;
  }

  .grid-cell {
    min-height: 30px;
    font-size: 0.78rem;
  }

  .players-panel {
    width: 100%;
  }

  .players-panel ul {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .players-panel li {
    font-size: 0.72rem;
  }

  .reveal-cards {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .session-strip {
    padding-right: 0;
  }

  .minimal-btn.logout-corner {
    position: static;
  }
}

@media (max-width: 760px) {
  .scene {
    padding: 1.6vh 2vw;
  }

  .players-panel {
    width: 100%;
  }

  .players-panel ul {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .controls-hint {
    font-size: 0.72rem;
  }

  .reveal-cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 94vw;
  }
}
