:root {
  color-scheme: dark;
  --bg: #05080f;
  --panel: rgba(13, 19, 31, 0.82);
  --panel-strong: rgba(17, 25, 39, 0.96);
  --line: rgba(145, 178, 218, 0.18);
  --text: #edf5ff;
  --muted: #91a4b8;
  --cyan: #66e8ff;
  --green: #8df7a5;
  --amber: #ffc267;
  --rose: #ff99c8;
  --violet: #b9a3ff;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.44);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  font-family: Inter, system-ui, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 18% 12%, rgba(102, 232, 255, 0.12), transparent 28rem),
    radial-gradient(circle at 80% 10%, rgba(185, 163, 255, 0.12), transparent 25rem),
    linear-gradient(180deg, #05080f 0%, #07101c 58%, #05080f 100%);
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
}

.ambient-grid {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(102, 232, 255, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(102, 232, 255, 0.055) 1px, transparent 1px);
  background-size: 52px 52px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.75), transparent 82%);
  animation: gridDrift 28s linear infinite;
}

.particle-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.particle-layer span {
  position: absolute;
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: var(--cyan);
  box-shadow: 0 0 24px var(--cyan);
  opacity: 0.34;
  animation: floatParticle 12s ease-in-out infinite;
}

.particle-layer span:nth-child(1) { left: 12%; top: 18%; }
.particle-layer span:nth-child(2) { left: 42%; top: 8%; animation-delay: -3s; background: var(--green); }
.particle-layer span:nth-child(3) { left: 72%; top: 22%; animation-delay: -6s; background: var(--rose); }
.particle-layer span:nth-child(4) { left: 84%; top: 62%; animation-delay: -8s; }
.particle-layer span:nth-child(5) { left: 20%; top: 72%; animation-delay: -5s; background: var(--amber); }

.shell {
  position: relative;
  z-index: 1;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 0;
  backdrop-filter: blur(18px);
}

.brand,
.topbar nav,
.badge-row,
.hero-actions,
.controls {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  font-weight: 800;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(102, 232, 255, 0.34);
  border-radius: 10px;
  color: var(--cyan);
  background: rgba(102, 232, 255, 0.08);
  font-family: "JetBrains Mono", monospace;
}

.topbar nav a,
.icon-button {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: rgba(9, 14, 23, 0.58);
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 860px);
  align-items: center;
  min-height: auto;
  padding: 48px 0 42px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--cyan);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 18px;
  font-size: clamp(3rem, 8vw, 6.8rem);
  line-height: 0.92;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 12px;
  font-size: clamp(1.65rem, 3vw, 2.5rem);
  letter-spacing: 0;
}

.tagline {
  max-width: 720px;
  color: #cfe0f3;
  font-size: clamp(1.1rem, 2vw, 1.45rem);
  font-weight: 700;
}

.hero-description,
.section-heading p,
.game-card-body > p,
.console-block p,
.table-core small {
  color: var(--muted);
  line-height: 1.65;
}

.hero-description {
  max-width: 720px;
  font-size: 1.05rem;
}

.button,
.icon-button {
  cursor: pointer;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  font-weight: 800;
}

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

.button.primary {
  border-color: rgba(102, 232, 255, 0.42);
  background: linear-gradient(135deg, rgba(102, 232, 255, 0.22), rgba(141, 247, 165, 0.14));
  box-shadow: 0 0 26px rgba(102, 232, 255, 0.14);
}

.button.secondary,
.button.ghost {
  background: rgba(255, 255, 255, 0.05);
}

.button:hover:not(:disabled),
.icon-button:hover {
  transform: translateY(-2px);
  border-color: rgba(102, 232, 255, 0.54);
}

.game-card,
.side-console,
.table,
.modal form {
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(17, 25, 39, 0.9), rgba(9, 13, 22, 0.86));
  box-shadow: var(--shadow);
}

.card-title-row,
.game-header,
.zone-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.scoreboard div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.035);
}

.scoreboard span,
.zone-label span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.scoreboard strong {
  display: block;
  margin-top: 4px;
  font-family: "JetBrains Mono", monospace;
}

.section {
  padding: 48px 0;
}

#games {
  padding-top: 28px;
}

.game-section {
  padding-top: 42px;
}

.section-heading {
  max-width: 720px;
  margin-bottom: 24px;
}

.game-card {
  display: grid;
  grid-template-columns: minmax(280px, 0.92fr) minmax(0, 1fr);
  overflow: hidden;
}

.game-card:hover {
  border-color: rgba(102, 232, 255, 0.5);
  box-shadow: 0 26px 80px rgba(0, 0, 0, 0.5), 0 0 32px rgba(102, 232, 255, 0.1);
}

.game-thumbnail {
  position: relative;
  min-height: 280px;
  background:
    linear-gradient(135deg, rgba(102, 232, 255, 0.18), rgba(255, 153, 200, 0.1)),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.04) 0 1px, transparent 1px 18px),
    #080f1c;
  overflow: hidden;
}

.game-thumbnail img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.terminal-lines {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 10px;
  padding: 28px;
  font-family: "JetBrains Mono", monospace;
  color: var(--green);
}

.terminal-lines span {
  width: fit-content;
  padding: 8px 10px;
  border: 1px solid rgba(141, 247, 165, 0.22);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.2);
}

.game-card-body {
  padding: 28px;
}

.win-summary {
  padding: 12px 14px;
  border: 1px solid rgba(141, 247, 165, 0.22);
  border-radius: 12px;
  color: #d9fbe2;
  background: rgba(141, 247, 165, 0.07);
  font-weight: 700;
}

.badge,
.badge-row span {
  border: 1px solid rgba(102, 232, 255, 0.22);
  border-radius: 999px;
  color: var(--cyan);
  background: rgba(102, 232, 255, 0.08);
  font-size: 0.78rem;
  font-weight: 800;
}

.badge {
  padding: 8px 10px;
}

.badge-row {
  flex-wrap: wrap;
  margin: 18px 0 24px;
}

.badge-row span {
  padding: 7px 10px;
}

.game-header {
  align-items: flex-end;
  margin-bottom: 22px;
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(4, minmax(72px, 1fr));
  gap: 10px;
  min-width: min(100%, 430px);
}

.game-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  gap: 18px;
}

.side-console {
  align-self: start;
  padding: 18px;
}

.console-block + .console-block {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.console-block h3 {
  margin-bottom: 8px;
  font-size: 0.95rem;
}

.rules-block {
  padding: 14px;
  border: 1px solid rgba(102, 232, 255, 0.2);
  border-radius: 14px;
  background: rgba(102, 232, 255, 0.045);
}

.hand-ranks {
  display: grid;
  gap: 7px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.hand-ranks li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 9px;
  border: 1px solid rgba(145, 178, 218, 0.14);
  border-radius: 9px;
  color: #dcecff;
  background: rgba(255, 255, 255, 0.035);
  font-size: 0.78rem;
}

.hand-ranks strong {
  color: var(--cyan);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.72rem;
}

.table {
  padding: 18px;
}

.hand-zone {
  min-height: 188px;
}

.zone-label {
  margin-bottom: 12px;
}

.zone-label strong {
  color: var(--cyan);
  text-align: right;
}

.cards {
  display: grid;
  grid-template-columns: repeat(5, minmax(96px, 1fr));
  gap: 10px;
}

.game-card-item {
  position: relative;
  min-height: 138px;
  padding: 12px;
  border: 1px solid rgba(145, 178, 218, 0.18);
  border-radius: 14px;
  color: var(--text);
  text-align: left;
  background:
    linear-gradient(160deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02)),
    rgba(8, 14, 24, 0.94);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.035);
  animation: cardIn 260ms ease both;
}

.game-card-item:hover,
.game-card-item.selected {
  transform: translateY(-4px);
  border-color: currentColor;
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.28), 0 0 24px color-mix(in srgb, currentColor 20%, transparent);
}

.game-card-item.replaced-card {
  border-color: rgba(255, 194, 103, 0.8);
  background:
    linear-gradient(160deg, rgba(255, 194, 103, 0.2), rgba(102, 232, 255, 0.08)),
    rgba(8, 14, 24, 0.94);
  box-shadow:
    inset 0 0 0 1px rgba(255, 194, 103, 0.18),
    0 0 28px rgba(255, 194, 103, 0.18);
  animation: cardIn 260ms ease both, replacedPulse 900ms ease-in-out 5;
}

.game-card-item strong {
  display: block;
  margin-top: 28px;
  font-size: clamp(0.88rem, 1.4vw, 1.02rem);
}

.game-card-item small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
}

.card-chip,
.card-rank,
.new-card-badge {
  position: absolute;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.72rem;
  font-weight: 800;
}

.card-chip {
  top: 10px;
  left: 10px;
}

.card-rank {
  right: 10px;
  bottom: 10px;
}

.new-card-badge {
  top: 10px;
  right: 10px;
  padding: 3px 6px;
  border: 1px solid rgba(255, 194, 103, 0.55);
  border-radius: 999px;
  color: var(--amber);
  background: rgba(255, 194, 103, 0.12);
  font-size: 0.58rem;
}

.suit-cyan { color: var(--cyan); }
.suit-amber { color: var(--amber); }
.suit-rose { color: var(--rose); }
.suit-green { color: var(--green); }

.hidden-card {
  color: var(--violet);
}

.center-table {
  display: grid;
  min-height: 154px;
  place-items: center;
  margin: 14px 0;
  border: 1px dashed rgba(102, 232, 255, 0.22);
  border-radius: 20px;
  background: radial-gradient(circle, rgba(102, 232, 255, 0.09), transparent 62%);
}

.table-core {
  display: grid;
  width: min(420px, 100%);
  min-height: 112px;
  place-items: center;
  padding: 20px;
  border-radius: 18px;
  text-align: center;
}

.table-core span {
  color: var(--cyan);
  font-family: "JetBrains Mono", monospace;
  font-weight: 800;
}

.table-core strong {
  margin-top: 8px;
  font-size: 1.05rem;
}

.controls {
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 18px;
}

.modal {
  width: min(680px, calc(100% - 32px));
  padding: 0;
  border: 0;
  color: var(--text);
  background: transparent;
}

.modal::backdrop {
  background: rgba(2, 4, 8, 0.72);
  backdrop-filter: blur(8px);
}

.modal form {
  position: relative;
  padding: 28px;
}

.modal ol {
  margin: 16px 0 0;
  padding-left: 20px;
  color: #cfe0f3;
  line-height: 1.7;
}

.modal-rule-note {
  margin-top: 18px;
  padding: 12px 14px;
  border: 1px solid rgba(102, 232, 255, 0.22);
  border-radius: 12px;
  color: #dcecff;
  background: rgba(102, 232, 255, 0.07);
  line-height: 1.55;
}

.modal-rule-note h3 {
  margin: 0 0 8px;
  font-size: 0.98rem;
}

.modal-rule-note h3 + p,
.modal-rule-note p {
  margin-bottom: 12px;
}

.score-example {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding: 12px;
  border: 1px solid rgba(255, 194, 103, 0.24);
  border-radius: 10px;
  background: rgba(255, 194, 103, 0.07);
}

.score-example span,
.score-example strong {
  display: block;
}

.score-example span {
  color: #f6dfbd;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.82rem;
}

.score-example strong {
  color: var(--amber);
}

.close-button {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.05);
  cursor: pointer;
}

.result-modal .button {
  margin-top: 18px;
}

@keyframes gridDrift {
  from { background-position: 0 0; }
  to { background-position: 52px 52px; }
}

@keyframes floatParticle {
  0%, 100% { transform: translate3d(0, 0, 0); }
  50% { transform: translate3d(16px, -24px, 0); }
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(14px) rotateX(14deg);
  }
  to {
    opacity: 1;
    transform: translateY(0) rotateX(0);
  }
}

@keyframes replacedPulse {
  0%, 100% {
    border-color: rgba(255, 194, 103, 0.8);
    box-shadow:
      inset 0 0 0 1px rgba(255, 194, 103, 0.18),
      0 0 24px rgba(255, 194, 103, 0.18);
  }
  50% {
    border-color: rgba(102, 232, 255, 0.95);
    box-shadow:
      inset 0 0 0 1px rgba(102, 232, 255, 0.22),
      0 0 38px rgba(102, 232, 255, 0.32);
    transform: translateY(-5px);
  }
}

@media (max-width: 920px) {
  .hero,
  .game-card,
  .game-layout {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
    padding: 34px 0 30px;
  }

  .game-header {
    display: block;
  }

  .scoreboard {
    margin-top: 16px;
  }
}

@media (max-width: 680px) {
  .shell {
    width: min(100% - 20px, 1180px);
  }

  .topbar {
    align-items: flex-start;
  }

  .topbar nav {
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
  }

  .topbar nav a,
  .icon-button {
    padding: 8px 9px;
    font-size: 0.82rem;
  }

  .hero-actions,
  .controls {
    align-items: stretch;
    flex-direction: column;
  }

  .button {
    width: 100%;
  }

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

  .cards {
    grid-template-columns: repeat(5, minmax(62px, 1fr));
    gap: 7px;
  }

  .game-card-item {
    min-height: 116px;
    padding: 9px;
    border-radius: 12px;
  }

  .game-card-item strong {
    margin-top: 25px;
    font-size: 0.75rem;
  }

  .game-card-item small {
    font-size: 0.67rem;
  }

  .card-chip,
  .card-rank {
    font-size: 0.62rem;
  }

  .table,
  .game-card-body,
  .side-console {
    padding: 14px;
  }
}

@media (max-width: 420px) {
  .brand span:last-child {
    display: none;
  }

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

  .hand-zone {
    min-height: 280px;
  }
}
