/* static/style.css — Baize game-table aesthetic with tactile ivory letter tiles */

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

:root {
  --table-bg: #133a2a;
  --table-deep: #0c261b;
  --tray-bg: #0a2016;
  --panel-bg: rgba(10, 32, 22, 0.72);
  --panel-border: rgba(243, 239, 227, 0.14);
  --tile-ivory: #fbf6e8;
  --tile-bevel: #d5c8aa;
  --tile-active: #ffd166;
  --tile-active-bevel: #d99b26;
  --tile-path: #95d5b2;
  --tile-path-bevel: #52b788;
  --ink: #1a1d1a;
  --text-light: #f3efe3;
  --text-muted: #b7c9be;
  --accent: #ffd166;
  --ok-bg: #1b4332;
  --ok-border: #52b788;
  --err-bg: #4a181c;
  --err-border: #e06c75;
  --warn-bg: #473212;
  --warn-border: #f4a261;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Plus Jakarta Sans", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text-light);
  background:
    radial-gradient(circle at 25% 15%, rgba(45, 106, 79, 0.45), transparent 55%),
    radial-gradient(circle at 80% 85%, rgba(8, 28, 21, 0.8), transparent 60%),
    var(--table-bg);
  padding: 1.5rem 1.25rem 2.5rem;
}

#app {
  max-width: 920px;
  margin: 0 auto;
}

/* ---------- Header & HUD ---------- */

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

h1 {
  margin: 0;
  font-size: 2.1rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.05;
  color: var(--text-light);
}

.subtitle {
  margin: 0.25rem 0 0;
  font-size: 0.92rem;
  color: var(--text-muted);
}

.hud {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.stat {
  display: flex;
  flex-direction: column;
  padding: 0.35rem 0.8rem;
  border-radius: 0.75rem;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  min-width: 72px;
}

.stat-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.timer {
  font-size: 1.35rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  padding: 0.55rem 0.95rem;
  border-radius: 0.75rem;
  background: var(--tray-bg);
  border: 1px solid var(--panel-border);
  color: var(--text-light);
  min-width: 78px;
  text-align: center;
}

.timer.low {
  background: var(--err-bg);
  border-color: var(--err-border);
  color: #ffb3b8;
}

.timer.off {
  color: var(--text-muted);
  opacity: 0.75;
}

/* ---------- Feedback shown in the word box above the board ---------- */

#current-word.is-feedback {
  letter-spacing: normal;
  font-size: 0.98rem;
  font-weight: 700;
}
#current-word.ok { color: var(--tile-path); border-color: rgba(149, 213, 178, 0.45); }
#current-word.error { color: #ffb3b8; border-color: rgba(224, 108, 117, 0.45); }
#current-word.warn { color: #ffe5c2; border-color: rgba(244, 162, 97, 0.45); }
#current-word.info { color: var(--text-muted); }

/* ---------- Main Two-Column Table Layout ---------- */

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 410px) 1fr;
  gap: 1.5rem;
  align-items: start;
}

.tray {
  background: var(--tray-bg);
  padding: 0.85rem;
  border-radius: 1.35rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 4px 16px rgba(0, 0, 0, 0.55), 0 14px 32px rgba(0, 0, 0, 0.35);
}

#board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.65rem;
  touch-action: none;
}

.tile {
  width: 100%;
  aspect-ratio: 1;
  background: var(--tile-ivory);
  color: var(--ink);
  border-radius: 0.9rem;
  border: 1px solid #fffdf7;
  border-bottom: 5px solid var(--tile-bevel);
  display: grid;
  place-items: center;
  font-size: 2rem;
  font-weight: 800;
  text-transform: uppercase;
  user-select: none;
  cursor: pointer;
  position: relative;
  transition: transform 0.08s ease, background-color 0.12s ease, border-color 0.12s ease;
}

.tile:hover {
  background: #ffffff;
}

.tile:active,
.tile.selected {
  transform: translateY(3px);
  border-bottom-width: 2px;
}

.tile.selected {
  background: var(--tile-active);
  border-color: #ffe399;
  border-bottom-color: var(--tile-active-bevel);
}

#board.game-over .tile {
  opacity: 0.55;
  cursor: default;
  pointer-events: none;
}

.tile.path {
  background: var(--tile-path);
  border-color: #b7e4c7;
  border-bottom-color: var(--tile-path-bevel);
}

.tile.path::after {
  content: attr(data-step);
  position: absolute;
  top: 5px;
  left: 6px;
  width: 19px;
  height: 19px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--tile-ivory);
  font-size: 0.72rem;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Live Word Pill & Controls ---------- */

#current-word {
  margin: 0 0 0.85rem;
  min-height: 2.5rem;
  padding: 0.45rem 0.9rem;
  border-radius: 0.75rem;
  background: var(--tray-bg);
  border: 1px solid var(--panel-border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

#current-word.has-word {
  color: var(--accent);
  border-color: rgba(255, 209, 102, 0.45);
}

.play-row {
  display: flex;
  gap: 0.55rem;
  margin-top: 0.7rem;
}

.play-row button {
  flex: 1;
}

button {
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  padding: 0.68rem 1rem;
  border-radius: 0.75rem;
  border: 1px solid var(--panel-border);
  background: var(--panel-bg);
  color: var(--text-light);
  cursor: pointer;
  transition: background-color 0.12s ease, transform 0.08s ease;
}

button:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
}

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

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

button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  color: var(--ink);
  border-color: var(--tile-active-bevel);
}

.btn-primary:hover:not(:disabled) {
  background: #ffe08a;
}

.toolbar {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.toolbar button {
  flex: 1 1 auto;
}

/* ---------- Word Ledger Column ---------- */

.ledger-column {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 1.1rem;
  padding: 1rem 1.1rem;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.65rem;
}

.panel-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-light);
}

.count-pill {
  font-size: 0.82rem;
  font-weight: 700;
  padding: 0.15rem 0.6rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-muted);
}

.empty-hint {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text-muted);
}

#found-list,
#all-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 290px;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(125px, 1fr));
  gap: 0.45rem;
}

#found-list li,
#all-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.42rem 0.65rem;
  border-radius: 0.55rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
}

#found-list li:hover,
#all-list li:hover {
  background: rgba(255, 255, 255, 0.13);
}

.found-item .word-text {
  color: var(--accent);
}

.found-item .score-badge {
  font-size: 0.78rem;
  color: var(--text-muted);
}

#all-list li.found {
  color: var(--tile-path);
  border-color: rgba(149, 213, 178, 0.35);
}

#all-list li.missed {
  color: var(--text-muted);
}

/* ---------- Popup screens ---------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: rgba(6, 18, 13, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: modal-fade 0.18s ease-out;
}
.modal-overlay[hidden] { display: none; }

.modal-card {
  width: min(420px, 100%);
  text-align: center;
  padding: 2rem 1.75rem 1.75rem;
  border-radius: 1.4rem;
  background: linear-gradient(160deg, #1b4332, var(--table-deep));
  border: 1px solid rgba(255, 209, 102, 0.35);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  animation: modal-rise 0.24s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.modal-icon {
  font-size: 3rem;
  line-height: 1;
  margin-bottom: 0.75rem;
}

.modal-card h2 {
  margin: 0 0 0.5rem;
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: -0.02em;
}

.modal-card p {
  margin: 0 0 1.4rem;
  font-size: 0.98rem;
  line-height: 1.5;
  color: var(--text-muted);
}

#modal-action {
  min-width: 160px;
  font-size: 1rem;
  padding: 0.8rem 1.4rem;
}

@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes modal-rise {
  from { opacity: 0; transform: translateY(18px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .modal-overlay, .modal-card { animation: none; }
}

/* ---------- Responsive ---------- */

@media (max-width: 760px) {
  .workspace {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 400px) {
  body {
    padding: 1rem 0.75rem 2rem;
  }
  .tile {
    font-size: 1.65rem;
    border-radius: 0.75rem;
  }
  #board {
    gap: 0.5rem;
  }
  h1 {
    font-size: 1.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tile,
  button {
    transition: none;
  }
}
