:root {
  color-scheme: dark;
  --bg: #202124;
  --panel: #2f3136;
  --panel-2: #3a3d42;
  --text: #f4f7fb;
  --muted: #b8c0ca;
  --board: #075da8;
  --board-edge: #043e72;
  --hole: #1b1d21;
  --red: #ec554c;
  --red-deep: #a92f2b;
  --yellow: #f7c53d;
  --yellow-deep: #c58a17;
  --green: #4bd6a3;
  --shadow: rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent 180px),
    var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input {
  font: inherit;
}

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

.app {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  padding-bottom: env(safe-area-inset-bottom);
}

.topbar {
  height: 58px;
  display: grid;
  grid-template-columns: 76px 1fr 76px;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  background: #292a2e;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 2px 10px var(--shadow);
}

.topbar h1 {
  margin: 0;
  font-size: 1.18rem;
  line-height: 1;
  text-align: center;
  color: #ff746d;
}

.plain-button,
.share-button {
  min-height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  cursor: pointer;
}

.plain-button:disabled,
.share-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.turn-strip {
  display: grid;
  grid-template-columns: minmax(82px, 1fr) minmax(76px, 120px) minmax(82px, 1fr);
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #e8f0f4;
  color: #34373c;
}

.player-lane {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  opacity: 0.58;
  transition: opacity 160ms ease, transform 160ms ease;
}

.player-lane.is-active {
  opacity: 1;
  transform: translateY(-1px);
}

.player-lane:last-child {
  justify-content: flex-end;
}

.player-token {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: block;
  border-radius: 50%;
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.2), inset 0 5px 0 rgba(255, 255, 255, 0.26);
}

.player-red .player-token {
  background: var(--red);
}

.player-yellow .player-token {
  background: var(--yellow);
}

.player-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.turn-track {
  height: 10px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--red), #f0a34f 50%, var(--yellow));
  position: relative;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.16);
}

.turn-puck {
  width: 28px;
  height: 28px;
  position: absolute;
  top: 50%;
  left: 0;
  border-radius: 50%;
  background: linear-gradient(90deg, var(--red) 0 50%, var(--yellow) 50% 100%);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.24);
  transform: translate(-3px, -50%);
  transition: transform 220ms ease;
}

.turn-puck.is-yellow {
  transform: translate(calc(100px - 25px), -50%);
}

.game {
  width: 100%;
  max-width: 560px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 0 auto;
  padding: 14px;
}

.status-band {
  min-height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 2px;
}

.status-text {
  margin: 0 0 4px;
  font-size: 1.28rem;
  font-weight: 800;
  line-height: 1.15;
}

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

.share-button {
  min-width: 82px;
  padding: 0 14px;
  background: #f1f5f9;
  color: #202124;
  border-color: transparent;
  font-weight: 700;
}

.board-shell {
  width: 100%;
  margin-top: 18px;
  margin-bottom: 0;
}

.column-preview {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  padding: 0 10px 8px;
  min-height: 30px;
}

.preview-dot {
  width: 24px;
  height: 24px;
  margin: 0 auto;
  border-radius: 50%;
  opacity: 0;
  transform: translateY(4px) scale(0.88);
  transition: opacity 160ms ease, transform 160ms ease;
}

.preview-dot.is-visible {
  opacity: 0.88;
  transform: translateY(0) scale(1);
}

.preview-dot.p1 {
  background: var(--red);
}

.preview-dot.p2 {
  background: var(--yellow);
}

.board-stage {
  width: 100%;
  aspect-ratio: 7 / 6;
  position: relative;
}

.board-grid {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: 6px;
  padding: 8px;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 24%),
    var(--board);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow:
    inset 0 -5px 0 var(--board-edge),
    0 12px 24px var(--shadow);
  z-index: 1;
}

.cell {
  min-width: 0;
  min-height: 0;
  position: relative;
  border-radius: 50%;
  background:
    radial-gradient(circle at 48% 42%, rgba(255, 255, 255, 0.08), transparent 38%),
    var(--hole);
  box-shadow:
    inset 0 4px 7px rgba(0, 0, 0, 0.68),
    0 1px 0 rgba(255, 255, 255, 0.12);
  overflow: hidden;
}

.cell::after {
  content: "";
  position: absolute;
  inset: 13%;
  border-radius: 50%;
  opacity: 0;
  transform: scale(0.92);
}

.cell.p1::after,
.cell.p2::after {
  opacity: 1;
  transform: scale(1);
}

.cell.p1::after,
.chip.p1 {
  background:
    radial-gradient(circle at 35% 26%, rgba(255, 255, 255, 0.3), transparent 18%),
    linear-gradient(160deg, #ff756d, var(--red) 58%, var(--red-deep));
}

.cell.p2::after,
.chip.p2 {
  background:
    radial-gradient(circle at 35% 26%, rgba(255, 255, 255, 0.32), transparent 18%),
    linear-gradient(160deg, #ffe173, var(--yellow) 58%, var(--yellow-deep));
}

.cell.is-win::after {
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 0.86),
    0 0 18px rgba(255, 255, 255, 0.7);
  animation: winPulse 900ms ease-in-out infinite alternate;
}

.falling-layer,
.column-triggers {
  position: absolute;
  inset: 0;
}

.falling-layer {
  pointer-events: none;
  overflow: hidden;
  z-index: 3;
}

.chip {
  position: absolute;
  left: 0;
  top: 0;
  border-radius: 50%;
  box-shadow:
    inset 0 -5px 0 rgba(0, 0, 0, 0.22),
    inset 0 4px 0 rgba(255, 255, 255, 0.24),
    0 6px 12px rgba(0, 0, 0, 0.28);
  will-change: transform;
}

.column-triggers {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  z-index: 5;
}

.column-trigger {
  appearance: none;
  border: 0;
  border-radius: 0;
  background: transparent;
  cursor: pointer;
}

.column-trigger:disabled {
  cursor: default;
}

.column-trigger:not(:disabled).is-hot {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), transparent 42%);
}

.bottom-bar {
  min-height: 54px;
  display: grid;
  grid-template-columns: 10px auto minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 8px 14px calc(8px + env(safe-area-inset-bottom));
  background: #292a2e;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--muted);
}

.connection-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #9299a3;
}

.connection-dot.is-online {
  background: var(--green);
  box-shadow: 0 0 10px rgba(75, 214, 163, 0.5);
}

.room-link {
  min-width: 0;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
}

@keyframes winPulse {
  from {
    filter: brightness(1);
  }

  to {
    filter: brightness(1.22);
  }
}

@media (min-width: 700px) {
  body {
    display: grid;
    place-items: center;
  }

  .app {
    width: min(560px, 100vw);
    min-height: min(860px, 100svh);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
  }

  .game {
    padding: 18px;
  }
}

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