:root {
  --bg: #030b18;
  --top-a: #1747a6;
  --top-b: #163373;
  --bottom-a: #0d7669;
  --bottom-b: #0c5753;
  --divider: #0b1324;
  --text: #f8fbff;
  --muted: #c7d6ec;
  --chip: rgba(248, 250, 252, 0.14);
  --chip-border: rgba(255, 255, 255, 0.38);
  --active: rgba(250, 204, 21, 0.48);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  color: var(--text);
  font-family: "Avenir Next", "Segoe UI", sans-serif;
  background: radial-gradient(circle at 20% 0%, #1e3a8a, var(--bg) 62%);
  overscroll-behavior: none;
  touch-action: manipulation;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#app {
  width: 100%;
  height: 100dvh;
  display: grid;
  grid-template-rows: 1fr auto 1fr;
}

.panel {
  position: relative;
  padding: max(8px, env(safe-area-inset-top)) 10px max(8px, env(safe-area-inset-bottom));
  overflow: hidden;
}

.panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 20% 10%, rgba(255, 255, 255, 0.16), transparent 55%);
}

.panel-top {
  background: linear-gradient(145deg, var(--top-a), var(--top-b));
}

.panel-bottom {
  background: linear-gradient(220deg, var(--bottom-a), var(--bottom-b));
}

.panel.is-active {
  box-shadow: inset 0 0 0 2px var(--active);
}

.panel.is-paused .panel-inner {
  opacity: 0.56;
  filter: grayscale(0.5);
}

.panel-inner {
  position: relative;
  z-index: 1;
  height: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr) auto;
  gap: 6px;
}

.rotated {
  transform: rotate(180deg);
  transform-origin: center;
}

.hud-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.score {
  font-size: clamp(0.9rem, 2.9vw, 1.1rem);
  font-weight: 800;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.word-count {
  font-size: clamp(0.75rem, 2.2vw, 0.88rem);
  font-weight: 700;
  color: #d7e6fb;
}

.guess-slots {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 4px;
}

.slot {
  min-height: clamp(24px, 4.5vh, 34px);
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(0, 0, 0, 0.18);
  display: grid;
  place-items: center;
  font-size: clamp(0.8rem, 2.6vw, 1rem);
  font-weight: 800;
}

.letter-buttons {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 4px;
}

.letter-btn {
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 999px;
  background: linear-gradient(180deg, #f8fafc, #d4dae3);
  color: #134d84;
  min-height: clamp(30px, 5.2vh, 38px);
  font-size: clamp(0.82rem, 2.5vw, 1rem);
  font-weight: 900;
}

.letter-btn:disabled {
  opacity: 0.4;
}

.action-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
}

.action-row button {
  border: 1px solid var(--chip-border);
  border-radius: 10px;
  background: var(--chip);
  color: var(--text);
  min-height: clamp(28px, 4.8vh, 36px);
  font-size: clamp(0.68rem, 2.1vw, 0.84rem);
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.action-row .enter-btn {
  background: linear-gradient(130deg, #10b981, #0f766e);
  border-color: rgba(110, 231, 183, 0.8);
}

.guessed-compact {
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 10px;
  background: rgba(2, 6, 23, 0.28);
  padding: 4px 5px;
  min-height: 0;
  overflow: hidden;
  display: grid;
  align-content: start;
  gap: 2px;
  font-size: 0.56rem;
  line-height: 1.1;
}

.guessed-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.guessed-title {
  font-weight: 800;
  color: #dbeafe;
  font-size: 0.56rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.guessed-count {
  font-size: 0.56rem;
  font-weight: 800;
  color: #dbeafe;
}

.guessed-body {
  min-height: 0;
  overflow: auto;
  display: grid;
  gap: 2px;
  align-content: start;
}

.guessed-compact.scale-sm {
  font-size: 0.51rem;
}

.guessed-compact.scale-xs {
  font-size: 0.46rem;
}

.guessed-row {
  display: grid;
  grid-template-columns: 10px 1fr 28px;
  gap: 3px;
  align-items: start;
  min-width: 0;
}

.guessed-len {
  font-weight: 900;
  color: #d8e7fb;
  text-align: right;
}

.guessed-len-count {
  color: #bfdbfe;
  font-weight: 700;
  text-align: right;
}

.guessed-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  color: #dbeafe;
  min-width: 0;
}

.guessed-pill {
  border: 1px solid rgba(148, 163, 184, 0.44);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.58);
  color: #dbeafe;
  padding: 0 4px;
  line-height: 1.18;
  font-weight: 700;
}

.unguessed-box {
  width: 0.5rem;
  height: 0.4rem;
  border: 1px solid rgba(226, 232, 240, 0.85);
  border-radius: 2px;
  display: inline-block;
  background: transparent;
  flex: 0 0 auto;
}

.guessed-empty {
  margin: 0;
  color: rgba(219, 234, 254, 0.72);
  font-size: 0.56rem;
}

.feedback {
  margin: 0;
  min-height: 1.05em;
  font-size: clamp(0.68rem, 2.2vw, 0.82rem);
  font-weight: 700;
  color: #e2e8f0;
}

.feedback.good {
  color: #86efac;
}

.feedback.bad {
  color: #fed7aa;
}

.divider {
  border-top: 2px solid rgba(255, 255, 255, 0.24);
  border-bottom: 2px solid rgba(255, 255, 255, 0.24);
  background: linear-gradient(90deg, #0f172a, var(--divider), #0f172a);
  display: grid;
  gap: 4px;
  justify-items: center;
  padding: 6px 10px;
}

.divider-main {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

.time-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #dbeafe;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.02em;
}

#roundMinutes {
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 9px;
  background: rgba(15, 23, 42, 0.82);
  color: #e2e8f0;
  font-size: 0.74rem;
  font-weight: 800;
  min-height: 30px;
  min-width: 58px;
  text-align: center;
}

.timer {
  margin: 0;
  min-width: 78px;
  text-align: center;
  font-size: clamp(1rem, 3vw, 1.15rem);
  font-weight: 900;
  letter-spacing: 0.04em;
}

.timer.warning {
  color: #fbbf24;
}

.control-btn {
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 10px;
  background: rgba(248, 250, 252, 0.15);
  color: var(--text);
  min-height: 30px;
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 800;
}

.control-link {
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 10px;
  background: rgba(248, 250, 252, 0.15);
  color: var(--text);
  min-height: 30px;
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 800;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

.pause-btn {
  min-width: 74px;
}

.status-text {
  margin: 0;
  font-size: clamp(0.7rem, 2.2vw, 0.84rem);
  color: var(--muted);
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(4px);
  display: grid;
  place-items: center;
  z-index: 30;
}

.overlay-card {
  width: min(92vw, 540px);
  max-height: 88dvh;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 16px;
  background: linear-gradient(170deg, #0f172a, #1e293b);
  text-align: center;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.overlay-card h2 {
  margin: 0 0 10px;
}

.overlay-card p {
  margin: 0;
  color: #d7e6fa;
}

.bonus-line {
  margin-top: 8px;
  color: #fef08a;
  font-size: 0.84rem;
}

.all-words-wrap {
  margin-top: 10px;
  text-align: left;
  display: grid;
  gap: 6px;
  min-height: 0;
}

.all-words-title {
  margin: 0;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.72rem;
  font-weight: 800;
  color: #d1deef;
}

.all-words-list {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  background: rgba(2, 6, 23, 0.46);
  padding: 8px;
  max-height: 38dvh;
  overflow: auto;
  display: grid;
  gap: 8px;
}

.all-words-section h3 {
  margin: 0 0 5px;
  font-size: 0.73rem;
  font-weight: 800;
  color: #bae6fd;
}

.word-pill-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.word-pill {
  border: 1px solid rgba(148, 163, 184, 0.5);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.6);
  color: #e2e8f0;
  padding: 2px 6px;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.all-words-empty {
  margin: 0;
  text-align: center;
  color: #94a3b8;
  font-size: 0.75rem;
}

.play-again {
  margin-top: 14px;
  border: 0;
  border-radius: 12px;
  min-height: 42px;
  min-width: 160px;
  font-size: 0.95rem;
  font-weight: 900;
  color: #fff;
  background: linear-gradient(120deg, #f59e0b, #f97316);
}

.hidden {
  display: none;
}

@media (max-height: 740px) {
  .panel-inner {
    gap: 4px;
  }

  .action-row button {
    min-height: 25px;
    font-size: 0.62rem;
  }

  .guessed-compact {
    padding: 3px 4px;
    font-size: 0.5rem;
  }

  .guessed-compact.scale-sm {
    font-size: 0.46rem;
  }

  .guessed-compact.scale-xs {
    font-size: 0.42rem;
  }

  .all-words-list {
    max-height: 32dvh;
  }
}
