:root {
  --bg: #0f172a;
  --panel: #111827;
  --panel2: #1f2937;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --border: #334155;
  --good: #22c55e;
  --bad: #ef4444;
  --warn: #f59e0b;
  --accent: #38bdf8;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: radial-gradient(circle at top, #1e293b 0%, #0f172a 55%, #020617 100%);
  color: var(--text);
  min-height: 100vh;
}

.table-wrap {
  max-width: 1250px;
  margin: 0 auto;
  padding: 20px;
}

.topbar {
  text-align: center;
  margin-bottom: 20px;
}

.topbar h1 {
  margin: 0 0 6px;
}

.topbar p {
  margin: 0;
  color: var(--muted);
}

.layout {
  display: grid;
  gap: 16px;
}

.panel {
  background: rgba(17, 24, 39, 0.96);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.25);
}

.panel h2 {
  margin-top: 0;
}

.score-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.card-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 86px;
}

.card {
  width: 68px;
  height: 84px;
  background: linear-gradient(180deg, #f8fafc, #e2e8f0);
  border-radius: 12px;
  color: #111827;
  position: relative;
  border: 2px solid #cbd5e1;
  box-shadow: 0 6px 14px rgba(0,0,0,0.22);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card.hidden {
  background: linear-gradient(180deg, #334155, #1e293b);
  border-color: #475569;
  color: #cbd5e1;
}

.card.empty {
  background: rgba(255,255,255,0.04);
  border: 2px dashed #475569;
  color: #64748b;
}

.letter {
  font-size: 2rem;
  font-weight: 800;
}

.value {
  position: absolute;
  right: 7px;
  bottom: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #334155;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

button {
  background: var(--accent);
  color: #08111f;
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 700;
  cursor: pointer;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.word-entry {
  margin-top: 16px;
  display: grid;
  gap: 8px;
}

.word-entry input {
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0b1220;
  color: var(--text);
  font-size: 1rem;
  text-transform: uppercase;
}

.info-line {
  margin-top: 12px;
  color: var(--muted);
}

.result-box,
.history-box {
  background: #0b1220;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px;
  min-height: 150px;
  line-height: 1.5;
  white-space: pre-line;
}

.history-entry {
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.history-entry:last-child {
  border-bottom: none;
}

.good { color: #86efac; }
.bad { color: #fca5a5; }
.warn { color: #fde68a; }

@media (min-width: 980px) {
  .layout {
    grid-template-columns: 1fr 1fr;
  }

  .scoreboard-panel,
  .community-panel,
  .history-panel {
    grid-column: 1 / -1;
  }
}

.difficulty-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.difficulty-row label {
  color: var(--muted);
  font-weight: 600;
}

.difficulty-row select {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #0b1220;
  color: var(--text);
  font-size: 0.95rem;
}

/* Small phone optimization */
@media (max-width: 473px) {

  .card {
    width: 52px;
    height: 64px;
  }

  .letter {
    font-size: 1.45rem;
  }

  .value {
    font-size: 0.7rem;
    right: 5px;
    bottom: 4px;
  }

  .card-row {
    gap: 6px;
  }

  .actions button {
    padding: 8px 10px;
    font-size: 0.85rem;
  }

  .word-entry input {
    font-size: 0.9rem;
    padding: 10px;
  }

  .card-row {
    justify-content: center;
  }
}