:root {
  --bg: #4f6da9;
  --panel: #171a21;
  --ink: #e8e8ea;
  --muted: #a9acb3;
  --accent: #6ea8fe;
  --good: #30c48d;
  --warn: #ffce56;
  --bad: #ff6b6b;
  --grid: #2a2f3a;
  --tile-bg: #f6f6f6;
  --tile-border: #111318;
}

* { 
  box-sizing: border-box; 
}

body {
  margin: 0; 
  background: var(--bg); 
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, "Helvetica Neue", Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

header {
  display: flex; 
  align-items: center; 
  justify-content: space-between;
  padding: 16px 20px; 
  border-bottom: 1px solid #20242e; 
  background: #12151c;
  position: sticky; 
  top: 0; 
  z-index: 10;
}

header h1 { 
  font-size: 20px; 
  margin: 0; 
  letter-spacing: 0.2px; 
}

header .sub { 
  color: var(--muted); 
  font-size: 13px; 
}

.wrap{
  width: min(1200px, calc(100vw - 32px));  /* overall play area width */
  margin: 90px auto 0;                      /* you said margin 90 works */
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 16px;
  align-items: start;
}

@media (max-width: 900px) {
  .wrap {
    grid-template-columns: 1fr;
    width: min(100%, 640px);
    margin: 0 auto;
  }

  #boardContainer{
    width: min(65vw, 720px);
    max-width: 720px;
  }
}

.card { 
  overflow: hidden;
  background: var(--panel); 
  border: 1px solid #20242e; 
  border-radius: 16px; 
  box-shadow: 0 10px 24px rgba(0,0,0,.25); 
}

.pad { 
  padding: 16px; 
}

.toolbar { 
  display: flex; 
  gap: 8px; 
  flex-wrap: wrap; 
}

button, .btn {
  background: #222734; 
  color: var(--ink); 
  border: 1px solid #2b3140; 
  border-radius: 12px; 
  padding: 10px 14px; 
  cursor: pointer;
  transition: transform .04s ease, background .2s ease, border-color .2s ease, box-shadow .2s ease;
}

button:hover { 
  background: #263044; 
  border-color: #344057; 
}

button:active { 
  transform: translateY(1px); 
}

.btn-primary {
  background: #222734;
  border-color: #2b3140;
}

/* hover / keyboard focus */
.btn-primary:hover,
.btn-primary:focus-visible {
  background: #2a3654;
  border-color: #6ea8fe;
  box-shadow: 0 0 0 3px rgba(110,168,254,.18);
}

/* click */
.btn-primary:active {
  background: #344469;
  border-color: #6ea8fe;
}

/* Make the board card a centering stage */
.board-section{
  display: flex;
  align-items: center;      /* horizontal */
  justify-content: center;  /* vertical */
}

#boardContainer {
  position: relative;
  aspect-ratio: 1 / 1;          /* keep the box square */
  width: clamp(520px, 72vmin, 720px);
  max-width: 720px;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#board { 
  width: 100%; 
  height: 100%; 
  display: block; 
  border-radius: 16px; 
}

.side {
  display: grid;
  gap: 12px;
  height: 100%;          /* ✅ KEY: allow filling the column height */
  grid-template-rows: 1fr auto;  /* ✅ Display grows, Score stays natural */
}

.pill { 
  background: #1a1f2a; 
  border: 1px solid #242b39; 
  padding: 10px 12px; 
  border-radius: 12px; 
  font-size: 14px; 
  color: var(--muted); 
}

.row { 
  display: flex; 
  gap: 8px; 
  align-items: center; 
  flex-wrap: wrap; 
}

.display{
  flex: 1;            /* ✅ fill remaining space inside the card */
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr)); /* 2 cols */
  grid-template-rows: repeat(3, 1fr);              /* 3 rows */
  gap: 8px;
  width: 100%;

  /* KEY: constant area, never shrinks */
  aspect-ratio: 2 / 3;  /* 2 columns by 3 rows */
}

.slot{
  width: 100%;
  aspect-ratio: 1 / 1;

  display: flex;
  align-items: center;
  justify-content: center;

  min-width: 0;
}

.slot.empty{
  opacity: 0.35;
  cursor: default;
}

.slot.sel { 
  outline: 2px solid var(--accent); 
}

.legend { 
  display: grid; 
  grid-template-columns: 1fr 1fr; 
  gap: 8px; 
  font-size: 13px; 
  color: var(--muted); 
}

.badge { 
  padding: 4px 8px; 
  border-radius: 999px; 
  background: #1e2533; 
  border: 1px solid #2b3446; 
  font-size: 12px; 
  color: var(--ink); 
}

.status { 
  font-size: 14px; 
  color: var(--muted); 
}

dialog { 
  border: 1px solid #2a3040; 
  border-radius: 16px; 
  background: #121723; 
  color: var(--ink); 
  box-shadow: 0 20px 60px rgba(0,0,0,.5); 
  width: min(720px, 92vw); 
}

dialog::backdrop { 
  background: rgba(0,0,0,0.45); 
  backdrop-filter: blur(2px); 
}

.modal-head { 
  padding: 16px 20px; 
  border-bottom: 1px solid #242b39; 
  font-weight: 600; 
}

.modal-body { 
  padding: 16px 20px; 
}

.modal-foot { 
  padding: 16px 20px; 
  border-top: 1px solid #242b39; 
  display: flex; 
  justify-content: flex-end; 
  gap: 8px; 
}

.choice { 
  display: grid; 
  grid-template-columns: 1fr 1fr; 
  gap: 12px; 
}

.choice label { 
  display: flex; 
  gap: 10px; 
  align-items: center; 
  background: #161b28; 
  border: 1px solid #273046; 
  padding: 12px; 
  border-radius: 12px; 
  cursor: pointer; 
}

.choice input { 
  accent-color: #6ea8fe; 
}

.hint { 
  color: var(--muted); 
  font-size: 13px; 
}

.hr { 
  height: 1px;
  background: #242b39; 
  margin: 12px 0; 
}

.side .card:first-child .pad {
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* Turn banner overlay */
#turnBanner {
  position: fixed;
  inset: 0;
  pointer-events: none;
  display: none;           /* shown via JS */
  z-index: 9999;
}

#turnBanner .banner-strip {
  position: absolute;
  top: 50%;
  left: 50%;
  /* start off-screen to the left; center is translate(-50%, -50%) */
  transform: translate(-120%, -50%);
  width: clamp(320px, 60vw, 900px);
  height: clamp(80px, 12vh, 140px);
  background: rgba(0, 0, 0, 0.65);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(1px);
}

#turnBanner #turnBannerText {
  font-size: clamp(28px, 5vw, 48px);
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.5px;
  text-shadow: 0 2px 12px rgba(0,0,0,.6);
}

/* Slower sweep → stop at center → hold → fade out */
#turnBanner .banner-strip.run {
  animation: turn-sweep-in 2.4s ease-in-out forwards;
}

@keyframes turn-sweep-in {
  /* slide in */
  0%   { transform: translate(-120%, -50%); opacity: 0; }
  50%  { transform: translate(-50%,  -50%); opacity: 1; }  /* reached center */
  /* hold at center */
  85%  { transform: translate(-50%,  -50%); opacity: 1; }
  /* fade away (still centered) */
  100% { transform: translate(-50%,  -50%); opacity: 0; }
}

.turn-active {
  outline: 2px solid var(--accent);
  border-radius: 10px;
  padding: 6px 8px;
  background: rgba(110, 168, 254, 0.10);
}

.turn-active-pill {
  outline: 2px solid var(--accent);
}

#volumeSlider {
  width: 140px;
  accent-color: var(--accent);
  cursor: pointer;
}