:root {
  --gold: #ffc233;
  --teal: #1fdc9a;
  --ink: #0d0b1e;
  --panel: rgba(16, 14, 38, 0.92);
  --edge: rgba(255, 194, 51, 0.5);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: var(--ink);
  font-family: 'Avenir Next', 'Trebuchet MS', Verdana, sans-serif;
  color: #fff;
  -webkit-user-select: none; user-select: none;
}

#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

#hud { position: fixed; inset: 0; pointer-events: none; display: flex; flex-direction: column; }
#hud > * { pointer-events: none; }
#hud button, #hud input { pointer-events: auto; }

/* ---------- top bar ---------- */
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; gap: 10px;
}
#logo {
  font-weight: 900; font-style: italic; letter-spacing: 1px;
  font-size: clamp(14px, 2vw, 20px); color: var(--gold);
  text-shadow: 0 2px 8px rgba(0,0,0,0.8);
  white-space: nowrap;
}
#logo span { font-size: 0.7em; color: #fff; margin: 0 3px; font-style: italic; }
#logo em { font-size: 0.65em; color: var(--teal); font-style: normal; }
#banner {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  background: var(--panel); border: 1px solid var(--edge); border-radius: 12px;
  padding: 6px 22px; box-shadow: 0 4px 18px rgba(0,0,0,0.5);
}
#roundLabel { font-size: 11px; letter-spacing: 2px; color: #bbb8d8; }
#categoryLabel { font-size: clamp(14px, 2.2vw, 20px); font-weight: 800; letter-spacing: 2px; color: var(--teal); }
.icon-btn {
  background: var(--panel); color: #fff; border: 1px solid var(--edge);
  border-radius: 10px; font-size: 18px; padding: 6px 10px; cursor: pointer;
}
.icon-btn:hover { background: rgba(50, 45, 90, 0.95); }

/* ---------- wedge banner ---------- */
#wedgeBanner {
  position: fixed; top: 20%; left: 50%; transform: translateX(-50%) scale(1);
  font-size: clamp(34px, 7vw, 72px); font-weight: 900; font-style: italic;
  color: var(--gold); text-shadow: 0 0 24px rgba(255,194,51,0.8), 0 4px 6px rgba(0,0,0,0.9);
  letter-spacing: 3px; transition: opacity 0.3s, transform 0.3s;
  animation: wedgePop 0.5s cubic-bezier(0.2, 2.4, 0.4, 1);
}
#wedgeBanner.hidden { opacity: 0; transform: translateX(-50%) scale(0.6); }
@keyframes wedgePop { from { transform: translateX(-50%) scale(0.3); } to { transform: translateX(-50%) scale(1); } }

/* ---------- message ---------- */
#messageBar {
  margin: 0 auto; max-width: min(720px, 92vw);
  background: var(--panel); border: 1px solid var(--edge); border-radius: 999px;
  padding: 8px 24px; font-size: clamp(13px, 1.8vw, 17px); text-align: center;
  min-height: 1.6em; box-shadow: 0 4px 18px rgba(0,0,0,0.5);
}

/* ---------- puzzle strip ---------- */
#puzzleStrip {
  margin: 8px auto 0; text-align: center;
  font-family: 'Courier New', monospace; font-weight: 700;
  font-size: clamp(15px, 2.6vw, 26px); letter-spacing: 4px; line-height: 1.5;
  color: #eaf6ff; text-shadow: 0 0 12px rgba(31,220,154,0.7), 0 2px 4px #000;
  white-space: pre; padding: 4px 18px; border-radius: 10px;
  background: rgba(8, 8, 22, 0.55);
}
#puzzleStrip:empty { display: none; }

/* ---------- scores ---------- */
#scores {
  margin-top: auto; display: flex; justify-content: center; gap: 14px;
  padding: 0 12px 8px;
}
.score-card {
  background: var(--panel); border: 2px solid rgba(255,255,255,0.15);
  border-radius: 14px; padding: 8px 18px; min-width: 132px; text-align: center;
  transition: border-color 0.3s, box-shadow 0.3s, transform 0.3s;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}
.score-card.active { transform: translateY(-6px) scale(1.05); }
.score-card .pname { font-size: 13px; font-weight: 800; letter-spacing: 2px; }
.score-card .pround { font-size: clamp(20px, 3vw, 30px); font-weight: 900; font-variant-numeric: tabular-nums; }
.score-card .ptotal { font-size: 11px; color: #bbb8d8; letter-spacing: 1px; }
.score-card .pprize { font-size: 11px; color: var(--gold); min-height: 13px; }

/* ---------- controls ---------- */
#controls { display: flex; flex-direction: column; align-items: center; gap: 8px; padding-bottom: 10px; }
#actionRow { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.action {
  font-family: inherit; font-weight: 800; letter-spacing: 1.5px;
  font-size: clamp(12px, 1.6vw, 15px); color: #fff;
  background: linear-gradient(180deg, #3b3670, #241f4e);
  border: 1px solid var(--edge); border-radius: 12px;
  padding: 10px 20px; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,0.5), inset 0 1px 0 rgba(255,255,255,0.2);
  transition: transform 0.12s, filter 0.12s;
}
.action:hover:not(:disabled) { transform: translateY(-2px); filter: brightness(1.25); }
.action:disabled { opacity: 0.35; cursor: not-allowed; }
.action.primary { background: linear-gradient(180deg, #d9a021, #a56e0c); color: #1b1206; border-color: #ffe9ad; }
.action.big { font-size: clamp(15px, 2.2vw, 20px); padding: 14px 34px; }

/* ---------- keyboard ---------- */
#keyboard {
  display: grid; grid-template-columns: repeat(13, 1fr); gap: 4px;
  background: var(--panel); border: 1px solid var(--edge); border-radius: 12px;
  padding: 8px; max-width: min(680px, 94vw);
}
#keyboard.hidden { display: none; }
.key {
  font-family: inherit; font-weight: 800; font-size: clamp(11px, 1.5vw, 15px);
  padding: 7px 0; text-align: center; border-radius: 7px; cursor: pointer;
  background: #2c2a55; color: #fff; border: 1px solid rgba(255,255,255,0.14);
  transition: transform 0.1s, background 0.15s;
}
.key:hover:not(:disabled) { background: #4a4590; transform: translateY(-2px); }
.key:disabled { opacity: 0.25; cursor: not-allowed; }
.key.vowel { background: #4a2a63; }
.key.flash-wrong { background: #a02020; }

#hint {
  text-align: center; font-size: 11px; color: rgba(255,255,255,0.45);
  letter-spacing: 1px; padding-bottom: 6px;
}

/* ---------- overlays ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  background: rgba(6, 5, 18, 0.72); backdrop-filter: blur(6px);
  transition: opacity 0.35s;
}
.overlay.hidden { opacity: 0; pointer-events: none; }
.panel {
  background: var(--panel); border: 2px solid var(--edge); border-radius: 22px;
  padding: clamp(20px, 4vw, 44px) clamp(24px, 5vw, 60px); text-align: center;
  box-shadow: 0 20px 80px rgba(0,0,0,0.8), 0 0 60px rgba(255,194,51,0.12);
  max-width: min(620px, 92vw); max-height: 88vh; overflow-y: auto;
}
.panel h1 {
  font-size: clamp(28px, 6vw, 54px); font-weight: 900; font-style: italic;
  color: var(--gold); letter-spacing: 2px;
  text-shadow: 0 0 30px rgba(255,194,51,0.5);
}
.panel h1 span { font-size: 0.55em; color: #fff; }
.panel h2 { font-size: clamp(22px, 4vw, 36px); font-weight: 900; color: var(--gold); letter-spacing: 3px; }
.subtitle { color: var(--teal); letter-spacing: 6px; font-weight: 700; margin: 6px 0 14px; }
.panel p { color: #d8d5ee; margin-bottom: 12px; }
.rules { list-style: none; text-align: left; margin: 0 auto 20px; max-width: 420px; }
.rules li { padding: 5px 0; color: #e8e6f8; font-size: clamp(12px, 1.7vw, 15px); }
.cat-chip {
  display: inline-block; margin: 14px 0 6px; padding: 8px 26px;
  background: #0e6f66; border: 2px solid var(--teal); border-radius: 999px;
  font-weight: 900; letter-spacing: 3px; font-size: clamp(14px, 2.4vw, 22px);
  box-shadow: 0 0 24px rgba(31,220,154,0.5);
}
#roundSummary, #finalScores { margin: 12px 0 18px; }
.summary-row {
  display: flex; justify-content: space-between; gap: 30px;
  padding: 6px 10px; font-size: clamp(13px, 2vw, 17px);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.summary-row .winner-tag { color: var(--gold); font-weight: 800; }
.summary-row.me { background: rgba(255,194,51,0.08); border-radius: 8px; }
.modal-cat { color: var(--teal); letter-spacing: 2px; font-weight: 700; margin: 8px 0 14px; }
#solveInput {
  width: 100%; font-family: inherit; font-size: clamp(15px, 2.2vw, 20px);
  letter-spacing: 2px; text-transform: uppercase; text-align: center;
  padding: 12px; border-radius: 12px; border: 2px solid var(--edge);
  background: #14122c; color: #fff; outline: none; margin-bottom: 16px;
}
#solveInput:focus { border-color: var(--teal); box-shadow: 0 0 18px rgba(31,220,154,0.4); }
.modal-row { display: flex; gap: 12px; justify-content: center; }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  #logo { display: none; }
  #scores { gap: 6px; padding-bottom: 4px; }
  .score-card { min-width: 0; flex: 1; padding: 6px 8px; }
  #keyboard { grid-template-columns: repeat(9, 1fr); }
  #hint { display: none; }
  #actionRow { gap: 6px; }
  .action { padding: 9px 12px; }
}
@media (max-height: 620px) {
  #puzzleStrip { display: none; }
  .panel { padding: 16px 22px; }
}
