/*
  Styles for the app
  Includes:
  - Home/Landing screen
  - Puzzle play screen
  - Solver results and replay controls
*/

:root {
  /* A better darker theme instead of the purple */
  --bg: #12110f;
  --bg-elevated: #1c1a17;
  --bg-card: #24211c;
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-strong: rgba(255, 255, 255, 0.12);
  --text: #ece8e1;
  --text-muted: #9c958b;
  --accent: #e3a008;
  --accent-soft: rgba(227, 160, 8, 0.15);
  --accent2: #5eead4;
  --accent2-soft: rgba(94, 234, 212, 0.12);
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.12);
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: ui-monospace, "Cascadia Code", "Consolas", monospace;
  --radius: 10px;
  --radius-sm: 7px;
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
}

.screen {
  display: none;
}
.screen.active {
  display: block;
}
.hidden {
  display: none !important;
}

/* --- home --- */
#home-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(227, 160, 8, 0.12), transparent),
    var(--bg);
}

.home-wrap {
  text-align: center;
  max-width: 520px;
}

.logo {
  font-size: clamp(2rem, 6vw, 2.75rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text);
}
.logo span {
  color: var(--accent);
  font-weight: 700;
}

.subtitle {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent2);
  margin-top: 10px;
}

.desc {
  color: var(--text-muted);
  font-size: 0.95rem;
  margin: 18px auto 8px;
  max-width: 34rem;
}

.desc-bio {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin: 0 auto 22px;
  max-width: 32rem;
  opacity: 0.92;
}

.desc-note {
  color: #d4cfc7;
  font-size: 0.78rem;
  margin: 8px auto 10px;
  max-width: 34rem;
}

.diff-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  max-width: 360px;
  margin: 0 auto;
}

@media (min-width: 520px) {
  .diff-grid {
    grid-template-columns: repeat(3, minmax(110px, 1fr));
    max-width: 430px;
  }
}

.diff-card {
  display: block;
  padding: 18px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  color: inherit;
  text-decoration: none;
  cursor: pointer;
  transition: border-color 0.15s, transform 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.diff-card:hover {
  border-color: var(--accent-soft);
  background: var(--bg-elevated);
  transform: translateY(-2px);
}

.diff-icon {
  width: 36px;
  height: 36px;
  margin: 0 auto 8px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  font-family: var(--font-mono);
  background: var(--border-subtle);
  color: var(--text);
}
.diff-icon--e { background: var(--accent2-soft); color: var(--accent2); }
.diff-icon--m { background: var(--accent-soft); color: var(--accent); }
.diff-icon--h { background: rgba(248, 113, 113, 0.15); color: #fca5a5; }
.diff-icon--x { background: rgba(167, 139, 250, 0.15); color: #c4b5fd; }

.diff-name {
  font-weight: 700;
  font-size: 0.95rem;
}
.diff-clue {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.credits {
  margin-top: 28px;
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* --- play chrome --- */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  padding: 0 2px;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  padding: 8px 14px;
  cursor: pointer;
  font-size: 0.82rem;
  font-family: inherit;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.btn-ghost:hover {
  background: var(--border-subtle);
  color: var(--text);
  border-color: var(--border-strong);
}

.top-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.badge {
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid rgba(227, 160, 8, 0.35);
}

.timer {
  font-family: var(--font-mono);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text);
}

.small-text {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.win-banner {
  text-align: center;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  font-weight: 600;
  font-size: 0.9rem;
  background: var(--accent2-soft);
  border: 1px solid rgba(94, 234, 212, 0.25);
  color: var(--accent2);
}

#play-screen {
  max-width: 880px;
  margin: 0 auto;
  padding: 16px 18px 32px;
}

.play-row {
  display: flex;
  gap: 24px;
  justify-content: center;
  align-items: flex-start;
  flex-wrap: wrap;
}

.board-col {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.side-col {
  width: 270px;
  min-width: 220px;
}
.side-col h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text);
}
.side-col p {
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.55;
  padding: 3px 0;
}

.dev-note {
  font-size: 0.72rem;
  color: var(--text-muted);
  opacity: 0.85;
  border-left: 2px solid var(--border-strong);
  padding-left: 10px;
  margin-top: 10px;
}

/* --- grid --- */
.board {
  display: inline-grid;
  grid-template-columns: repeat(9, 44px);
  grid-template-rows: repeat(9, 44px);
  background: #0d0c0b;
  border-radius: var(--radius);
  border: 2px solid var(--border-strong);
  overflow: hidden;
}

.cell {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 1rem;
  cursor: pointer;
  user-select: none;
  transition: background 0.08s;
  border-right: 1px solid rgba(255, 255, 255, 0.04);
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}
.cell.br {
  border-right: 2px solid rgba(255, 255, 255, 0.14);
}
.cell.bb {
  border-bottom: 2px solid rgba(255, 255, 255, 0.14);
}
.cell.original {
  color: #d6d0c8;
  font-weight: 700;
  cursor: default;
}
.cell.user-val {
  color: var(--accent);
  font-weight: 600;
}
.cell.selected {
  background: var(--accent-soft);
}
.cell.highlight {
  background: rgba(255, 255, 255, 0.03);
}
.cell.same-val {
  background: rgba(227, 160, 8, 0.08);
}
.cell.error {
  color: var(--danger) !important;
  background: var(--danger-soft) !important;
}
.cell.hint-glow {
  background: rgba(251, 191, 36, 0.2);
  animation: pulse 0.85s ease infinite;
}
.cell.hint-pop {
  color: #fcd34d !important;
  animation: pop 0.35s ease;
}
.cell.solved-cell {
  color: var(--accent2);
  font-weight: 600;
}

@keyframes pulse {
  0%,
  100% {
    box-shadow: inset 0 0 6px rgba(251, 191, 36, 0.12);
  }
  50% {
    box-shadow: inset 0 0 12px rgba(251, 191, 36, 0.22);
  }
}

@keyframes pop {
  0% {
    transform: scale(0.85);
    opacity: 0.5;
  }
  50% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.numpad {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 5px;
  margin-top: 12px;
  width: 100%;
  max-width: calc(9 * 44px + 8 * 5px);
}

.num-btn {
  padding: 9px 0;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--accent2);
  font-size: 0.95rem;
  font-weight: 700;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}
.num-btn:hover {
  background: var(--bg-card);
  border-color: var(--border-strong);
}
.num-btn.done {
  opacity: 0.25;
  cursor: default;
}

.actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
  width: 100%;
  max-width: calc(9 * 44px + 8 * 5px);
}

.act-btn {
  flex: 1;
  padding: 9px 8px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: transparent;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}
.act-btn:hover {
  background: var(--border-subtle);
  color: var(--text);
}
.hint-btn {
  border-color: rgba(251, 191, 36, 0.25);
  color: #fcd34d;
}
.ai-btn.on {
  background: var(--accent-soft);
  border-color: rgba(227, 160, 8, 0.45);
  color: var(--accent);
}

.box {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.55;
}
.rules-box {
  background: rgba(255, 255, 255, 0.03);
}
.stats-box {
  background: var(--accent2-soft);
}
.box-label {
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  margin-bottom: 4px;
  color: var(--text-muted);
}
.rules-box .box-label {
  color: var(--accent2);
}
.stats-box .box-label {
  color: var(--accent2);
}

.ai-sub {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.algo-btn {
  display: flex;
  align-items: center;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-card);
  cursor: pointer;
  margin-bottom: 7px;
  font-family: inherit;
  color: inherit;
  gap: 10px;
  text-align: left;
  transition: border-color 0.12s, background 0.12s;
}
.algo-btn:hover {
  border-color: var(--border-strong);
  background: var(--bg-elevated);
}

.algo-ic {
  font-size: 0.72rem;
  font-weight: 800;
  font-family: var(--font-mono);
  flex-shrink: 0;
  width: 2rem;
  color: var(--accent);
}
.algo-nm {
  font-weight: 700;
  font-size: 0.82rem;
}
.algo-tg {
  font-size: 0.68rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.algo-ar {
  margin-left: auto;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* results screen */
#result-screen {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px 20px 40px;
}

.res-top {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.res-title {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.res-title span {
  font-size: 1.75rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--accent);
}
.res-title h1 {
  font-size: 1.35rem;
  font-weight: 800;
}
.res-tag {
  color: var(--accent2);
  font-size: 0.8rem;
  font-weight: 600;
  margin-top: 2px;
}

.res-row {
  display: flex;
  gap: 22px;
  flex-wrap: wrap;
}

.res-left {
  flex: 1;
  min-width: 260px;
}
.res-right {
  width: 340px;
  min-width: 280px;
}
.res-right h3 {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
}
.card h3 {
  font-size: 0.85rem;
  font-weight: 700;
  margin-bottom: 6px;
}
.card p {
  color: #d4cfc7;
  font-size: 0.84rem;
  line-height: 1.55;
}

.res-note {
  color: var(--text-muted);
  font-size: 0.74rem;
  line-height: 1.45;
  margin-bottom: 8px;
}

.replay-btn {
  margin-top: 10px;
  width: fit-content;
}

.replay-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.met-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.met-card {
  background: var(--bg);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.met-label {
  font-size: 0.58rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.met-val {
  font-size: 1rem;
  font-weight: 800;
  font-family: var(--font-mono);
  margin-top: 2px;
}

.sm-board {
  grid-template-columns: repeat(9, 32px) !important;
  grid-template-rows: repeat(9, 32px) !important;
}
.sm-board .cell {
  width: 32px !important;
  height: 32px !important;
  font-size: 0.78rem !important;
}
