:root{
  --bgPurple:#5a2a3b;
  --bgGold:#e07c30;

  --purple:#4b1972;
  --purple2:#2a0b42;
  --gold:#f5c400;
  --gold2:#ffd84a;

  --gap: clamp(10px, 1.6vh, 18px);
  --pad: clamp(12px, 2.2vw, 28px);

  --radius: 14px;
  --tileRadius: 16px;

  --shadow: 0 14px 30px rgba(0,0,0,0.25);
  --shadow2: 0 10px 22px rgba(0,0,0,0.22);

  /* Controls (uniform ghost style) */
  --ctl-h: 44px;
  --ctl-r: 12px;
  --ctl-b: 2px;
  --ctl-shadow: 0 6px 14px rgba(0,0,0,0.18);
  --ctl-shadow-hover: 0 8px 16px rgba(0,0,0,0.22);
}

*{ box-sizing:border-box; }
html,body{ height:100%; }

body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  color:#fff;

  background: linear-gradient(
    180deg,
    var(--bgPurple) 0%,
    #7a3551 40%,
    var(--bgGold) 100%
  );
}

/* SCREEN */
.screen{
  min-height: 100dvh;
  padding: var(--pad);

  display:grid;
  grid-template-rows: auto 1fr auto;
  gap: var(--gap);
  align-content: stretch;

  background: linear-gradient(
    180deg,
    var(--bgPurple) 0%,
    #7a3551 40%,
    var(--bgGold) 100%
  );
}

.screen:fullscreen{
  background: linear-gradient(
    180deg,
    var(--bgPurple) 0%,
    #7a3551 40%,
    var(--bgGold) 100%
  );
}

/* HEADER (logos + title) */
.headerBar{
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-areas: "left title right";
  align-items: center;
  column-gap: clamp(10px, 1.6vw, 18px);
  row-gap: clamp(8px, 1.2vh, 14px);
}

.headerLogo{
  height: clamp(41px, 5.5vw, 84px);
  width: auto;
  max-width: min(260px, 32vw);
  object-fit: contain;
  display: block;
}

.headerLogo--left{ grid-area: left; justify-self: start; }
.headerLogo--right{ grid-area: right; justify-self: end; }

/* TITLE */
.title{
  grid-area: title;
  margin: 0;
  width: min(1200px, 100%);
  justify-self: center;
  text-align: center;

  font-weight: 800;
  letter-spacing: 0.3px;
  font-size: clamp(22px, 3vw, 40px);
  line-height: 1.2;

  padding: clamp(10px, 1.1vw, 14px) clamp(14px, 1.6vw, 22px);
  border-radius: 12px;

  color: var(--gold2);
  background: var(--purple2);
  border: 3px solid var(--gold);
  box-shadow: var(--shadow2);
}

/* ============================= */
/* CONTROLS (UNIFIED LOOK, SELECT DOES NOT MOVE) */
/* ============================= */

/* Base look shared by buttons + select */
.btn,
.modeSelect{
  height: var(--ctl-h);
  border-radius: var(--ctl-r);
  border: var(--ctl-b) solid var(--purple);
  box-shadow: var(--ctl-shadow);

  background: var(--gold);
  color: #fff;
  font-weight: 500;
}

/* Buttons (these DO animate) */
.btn{
  padding: 0 16px;
  cursor:pointer;
  user-select:none;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap: 8px;

  transition: transform 90ms ease, box-shadow 120ms ease, background 120ms ease, filter 120ms ease;
}

/* Ensure any old class variants don’t change appearance */
.btn--primary,
.btn--ghost{
  background: var(--gold);
  color:#fff;
  border-color: var(--purple);
}

@media (hover:hover){
  .btn:hover{
    box-shadow: var(--ctl-shadow-hover);
    transform: translateY(-1px);
    background: rgba(0,0,0,0.32);
    filter: brightness(1.02);
  }
}

.btn:active{
  transform: translateY(1px);
  box-shadow: 0 4px 10px rgba(0,0,0,0.16);
}

.btn:focus-visible{
  outline: 3px solid rgba(245,196,0,0.6);
  outline-offset: 2px;
}

.btn--icon{
  width: var(--ctl-h);
  padding: 0;
}

/* Select wrapper draws a stable chevron */
.selectWrap{
  position: relative;
  display:inline-flex;
  align-items:center;
}

/* Chevron overlay (never moves) */
.selectWrap::after{
  content:"";
  position:absolute;
  right: 14px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--gold);
  border-bottom: 2px solid var(--gold);
  transform: translateY(-60%) rotate(45deg);
  pointer-events:none;
  opacity: 0.95;
}

/* Select itself: NO transform/press animations */
.modeSelect{
  appearance:none;
  -webkit-appearance:none;
  -moz-appearance:none;

  padding: 0 44px 0 14px; /* room for the chevron */
  min-width:min(360px, 55vw);
  cursor: pointer;

  transition: background 120ms ease, box-shadow 120ms ease;
}

@media (hover:hover){
  .modeSelect:hover{
    background: rgba(0,0,0,0.32);
    box-shadow: var(--ctl-shadow-hover);
  }
}

/* No :active transform for select */
.modeSelect:active{
  transform: none;
}

.modeSelect:focus-visible{
  outline: 3px solid rgba(245,196,0,0.6);
  outline-offset: 2px;
}

/* BOARD */
.boardWrap{
  display:flex;
  align-items:center;
  justify-content:center;
}

.boardFrame{
  width:min(1400px, 100%);
  padding:clamp(10px, 1.2vw, 16px);
  border-radius:var(--radius);
  background:rgba(0,0,0,0.14);
  border:4px solid rgba(245,196,0,0.55);
  box-shadow:var(--shadow);
}

.board{
  --cols:6;
  display:grid;
  grid-template-columns:repeat(var(--cols), minmax(0,1fr));
  gap:clamp(10px, 1.1vw, 16px);
}

/* TILES */
.tile{
  position:relative;
  border-radius:var(--tileRadius);
  background:#f0c81b;
  border:3px solid rgba(75,25,114,0.9);
  box-shadow:0 10px 20px rgba(0,0,0,0.18);
  cursor:pointer;

  aspect-ratio:1 / 1;

  display:flex;
  align-items:center;
  justify-content:center;
  padding:6px;
  overflow:hidden;

  transition: transform 120ms ease;
}

.tile:hover{
  transform: translateY(-3px);
}

.tileInner{
  width:100%;
  height:100%;
  border-radius:calc(var(--tileRadius) - 6px);
  border:3px solid rgba(42,11,66,0.75);
  display:flex;
  align-items:center;
  justify-content:center;
  text-align:center;
  padding:10px;
  container-type: inline-size;
}

.tileText{
  color:var(--purple);
  font-weight:800;
  line-height:1.15;
  font-size: clamp(12px, 7cqw, 26px);
}

/* Revealed states */
.tile.is-revealed{
  cursor:default;
  filter:saturate(0.92);
}

.tile.is-correct{
  background:linear-gradient(180deg, #ffe37a, #f0c81b);
}

.tile.is-wrong{
  background:linear-gradient(180deg, #ffb1b1, #ff6a6a);
}

/* Mark reveal */
.tileMark{
  position:absolute;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size: clamp(40px, 25cqw, 160px);
  font-weight:1000;
  text-shadow:0 12px 28px rgba(0,0,0,0.35);
  transform:scale(0);
  opacity:0;
  pointer-events:none;
}

.tile.is-revealed .tileMark{
  transform:scale(1);
  opacity:1;
  transition:transform 220ms ease, opacity 220ms ease;
}

/* STATUS (base styling reused in bottom bar) */
.status{
  width:fit-content;
  max-width:1400px;
  margin:0 auto;
  padding:10px 14px;
  border-radius:10px;
  background:rgba(42,11,66,0.70);
  border:3px solid rgba(245,196,0,1);
  color:var(--gold2);
  font-weight:700;
  box-shadow:0 10px 18px rgba(0,0,0,0.18);
}

/* ============================= */
/* BOTTOM BAR (Score / Status / Timer) */
/* ============================= */

.bottomBar{
  max-width:1400px;
  margin:0 auto;
  width:100%;

  display:grid;
  grid-template-columns: 160px 1fr 160px;
  gap: var(--gap);
  align-items:stretch;
}

/* Small framed “cards” left/right */
.bottomCard{
  border-radius:12px;
  background: var(--purple2);
  border:3px solid var(--gold);
  box-shadow: var(--shadow2);

  padding: 10px 12px;
  display:flex;
  flex-direction:column;
  justify-content:center;
  align-items:center;
  text-align:center;
}

.bottomLabel{
  font-size:13px;
  font-weight:700;
  opacity:0.9;
  color: var(--gold2);
  margin-bottom: 4px;
}

.bottomValue{
  font-size: clamp(22px, 2.2vw, 34px);
  font-weight:900;
  color:#fff;
  line-height:1;
}

.bottomValue--timer{
  letter-spacing: 0.5px;
}

/* Center status: fill the middle column neatly */
.bottomStatus{
  margin:0;
  width:100%;
  max-width:none;
  display:flex;
  align-items:center;
  justify-content:center;
  text-align:center;
  font-size: clamp(20px, 2.5vw, 30px);
}

/* RESPONSIVE */

@media (max-width:980px){
  /* Tablet: logos above title (keep left/right alignment) */
  .headerBar{
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "left right"
      "title title";
  }
  .headerLogo--left{ justify-self: start; }
  .headerLogo--right{ justify-self: end; }
}

@media (max-width:860px){
  .board{ --cols:4; }
}

@media (max-width:700px){
  .bottomBar{
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "score timer"
      "status status";
  }

  .bottomCard--score{ grid-area: score; }
  .bottomCard--timer{ grid-area: timer; }
  .bottomStatus{ grid-area: status; }
}

@media (max-width:600px){
  .board{ --cols:3; }
.tile{ padding: 10px; }
  .tileInner{ padding: 8px; }
  /* Header: logos above title on mobile */
  .headerBar{
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "left right"
      "title title";
  }
  .headerLogo--left{ justify-self: start; }
  .headerLogo--right{ justify-self: end; }

}

@media (max-width:520px){
  .board{ --cols:3; }
}

@media (max-width:420px){
  .board{ --cols:2; }

  .bottomBar{
    grid-template-columns: 1fr;
    grid-template-areas:
      "score"
      "timer"
      "status";
  }
}

/* OVERLAY */
.overlay{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,0.45);
  display:flex;
  align-items:center;
  justify-content:center;
  padding:clamp(14px, 3vw, 30px);
  z-index:10;
}

.overlayCard{
  width:min(720px, 100%);
  border-radius:18px;
  background:rgba(75,25,114,0.92);
  border:3px solid rgba(245,196,0,0.7);
  box-shadow:var(--shadow);
  padding:clamp(16px, 2.4vw, 26px);
  color:#fff;
  text-align:center;

  max-height: 85dvh;
  overflow: auto;
}

.overlayLogoWrap{
  display:flex;
  justify-content:center;
  align-items:center;
  margin-bottom: 10px;
}

.overlayLogo{
  width: min(260px, 70vw);
  max-width: 100%;
  max-height: 180px;
  height: auto;
  object-fit: contain;
  display:block;
}

.overlayTitle{
  margin:8px 0 12px;
  color:var(--gold2);
  font-size:clamp(22px, 2.6vw, 34px);
  font-weight:800;
}

.overlayList{
  text-align:left;
  max-width:520px;
  margin:0 auto 16px;
  padding-left:18px;
  line-height:1.5;
  font-weight:600;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce){
  .tileMark{ transition:none !important; }
  .btn{ transition:none !important; }
  .btn:hover,
  .btn:active{ transform:none; box-shadow:none; }
  .tile:hover{ transform:none; }
}

@media (min-width: 1200px){
  .tileText{
    font-size: clamp(14px, 13cqw, 34px);
  }
}
/* ============================
   V7: Entry-mode via query params (?mode=teacher|student)
   ============================ */
body[data-entrymode] .selectWrap{
  display:none !important;
}
/* ============================
   V5.2: Overlay button stack
   ============================ */
.overlayBtns{
  display:flex;
  flex-direction:column;
  gap:12px;
}
/* ============================
   V5.3 (safe): Mute button hidden (sound policy handled in JS)
   ============================ */
#muteBtn{ display:none !important; }


/* ============================
   V6.3: Status CTA — status becomes restart button at round end
   ============================ */
.status.is-action{
  background: var(--gold);
  color:#fff;
  border-color: var(--purple);
  box-shadow: var(--ctl-shadow-hover);
  cursor:pointer;
  user-select:none;
}
@media (hover:hover){
  .status.is-action:hover{
    transform: translateY(-1px);
    filter: brightness(1.02);
  }
}
.status.is-action:active{
  transform: translateY(1px);
}
.status.is-action:focus-visible{
  outline: 3px solid rgba(245,196,0,0.6);
  outline-offset: 2px;
}


/* ============================
   V6: Truth vs History (end-state) — FLATTENED GREY
   Truth: ✓/✕ (and reveal rules)
   History: tiles never picked use a uniform grey (same for correct/wrong)
   ============================ */
.board.is-ended .tile.is-unpicked{
  background: linear-gradient(180deg, #d9d9d9, #bdbdbd) !important;
  border-color: rgba(75,25,114,0.55);
  box-shadow: 0 10px 20px rgba(0,0,0,0.14);
  opacity: 1;
  filter: none;
}
.board.is-ended .tile.is-unpicked .tileInner{
  border-color: rgba(42,11,66,0.55);
}
.board.is-ended .tile.is-unpicked .tileText{
  color: rgba(42,11,66,0.95);
  opacity: 0.9;
}
.board.is-ended .tile.is-unpicked.is-revealed .tileMark{
  opacity: 1;
  text-shadow: 0 14px 30px rgba(0,0,0,0.45);
}
.board.is-ended .tile.is-unpicked:hover{
  transform: none;
}

/* ============================
   V6.x: Confetti Burst (win celebration)
   Uses brand vars: --gold, --gold2, --purple, --purple2
   Decorative only (no layout / no input blocking)
   ============================ */
.confettiShard{
  position:fixed;
  top:50%;
  left:50%;
  width: var(--w, 14px);
  height: var(--h, 24px);
  opacity: 0.95;
  transform-origin:center;
  pointer-events:none;
  border-radius: 3px;
  will-change: transform, opacity;
  animation: confettiBurst 1.45s ease-out forwards;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.16);
  z-index: 9999; /* above overlay/board, still non-interactive */
}

@keyframes confettiBurst{
  to{
    transform: translate(var(--x), var(--y)) rotate(720deg);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce){
  .confettiShard{ animation: none !important; opacity: 0 !important; }
}


/* ============================
   PASS C: Hide legacy Mode dropdown + label (visual only)
   Logic untouched
   ============================ */
.modeLabel{
  display:none !important;
}

.selectWrap{
  display:none !important;
}
