/* Urordle — Mobile-first stylesheet */

:root {
  --bg: #0b1216;
  --bg-elev: #121b21;
  --bg-elev-2: #1a262d;
  --fg: #ecf2f5;
  --fg-muted: #98a8b0;
  --fg-dim: #5e7079;
  --accent: #2aa4c8;
  --accent-dark: #0f3a4f;
  --gold: #f4c95d;
  --green: #3aa55c;
  --amber: #d39942;
  --red: #d8584b;
  --border: #233138;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-1: 0 1px 2px rgba(0,0,0,.3), 0 4px 12px rgba(0,0,0,.18);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "SF Pro Text", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  min-height: 100%;
  overscroll-behavior-y: contain;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom);
}

/* Header */
.header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(180deg, var(--accent-dark), #0e2e3e);
  border-bottom: 1px solid #0b2531;
  padding-top: env(safe-area-inset-top);
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 720px;
  margin: 0 auto;
  padding: 12px 16px;
}
.brand {
  margin: 0;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #f6f8f9;
}
.brand-accent { color: var(--gold); }
.header-actions { display: flex; gap: 6px; }

.icon-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.18);
  color: #f6f8f9;
  width: 38px; height: 38px;
  border-radius: 999px;
  font-size: 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms ease, transform 80ms ease;
}
.icon-btn:hover { background: rgba(255,255,255,0.08); }
.icon-btn:active { transform: scale(0.95); }

/* Main */
.main {
  flex: 1;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Case area */
.case-area {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-1);
}
.case-meta {
  font-size: 12px;
  color: var(--fg-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}
.dot { margin: 0 6px; opacity: 0.6; }
.clue-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.clue-list li {
  font-size: 15.5px;
  line-height: 1.5;
  padding-left: 22px;
  position: relative;
  color: var(--fg);
  animation: fade-in 240ms ease;
}
.clue-list li::before {
  content: counter(clue);
  counter-increment: clue;
  position: absolute;
  left: 0; top: 0;
  width: 18px; height: 18px;
  font-size: 10px;
  font-weight: 700;
  border-radius: 999px;
  background: var(--accent);
  color: #06181f;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.clue-list { counter-reset: clue; }

@keyframes fade-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Guesses */
.guesses {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.guess-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  font-size: 14.5px;
  animation: pop 180ms ease;
}
@keyframes pop {
  0% { opacity: 0; transform: scale(0.97); }
  100% { opacity: 1; transform: scale(1); }
}
.guess-row .pill {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 8px;
  border-radius: 999px;
  flex-shrink: 0;
}
.guess-row.wrong .pill { background: rgba(216, 88, 75, 0.18); color: #ee9087; }
.guess-row.correct .pill { background: rgba(58, 165, 92, 0.18); color: #7fd29a; }
.guess-row.close .pill { background: rgba(211, 153, 66, 0.2); color: #ecbb6d; }
.guess-row.skip .pill { background: rgba(152, 168, 176, 0.18); color: #bbcdd3; }
.guess-row .text { flex: 1; color: var(--fg); }
.guess-row.correct { border-color: rgba(58, 165, 92, 0.4); }

/* Input */
.input-area {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: var(--shadow-1);
}
.autocomplete { position: relative; }
#guess-input {
  width: 100%;
  font-family: var(--font);
  font-size: 16px;
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  color: var(--fg);
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
#guess-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(42, 164, 200, 0.18);
}
#guess-input::placeholder { color: var(--fg-dim); }

.autocomplete-list {
  position: absolute;
  bottom: calc(100% + 6px);
  left: 0; right: 0;
  list-style: none;
  margin: 0;
  padding: 4px;
  max-height: 240px;
  overflow-y: auto;
  background: var(--bg-elev-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 -4px 12px rgba(0,0,0,0.3);
  display: none;
  z-index: 10;
}
.autocomplete-list.open { display: block; }
.autocomplete-list li {
  padding: 10px 12px;
  font-size: 15px;
  cursor: pointer;
  border-radius: 6px;
  color: var(--fg);
}
.autocomplete-list li[aria-selected="true"],
.autocomplete-list li:hover {
  background: rgba(42, 164, 200, 0.16);
  color: #d9eef5;
}

.action-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.btn {
  flex: 1;
  border: none;
  font-family: var(--font);
  font-size: 15.5px;
  font-weight: 600;
  padding: 13px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 120ms ease, transform 80ms ease, opacity 120ms ease;
  min-height: 46px;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: var(--accent);
  color: #06181f;
}
.btn-primary:hover { background: #34b3d7; }
.btn-secondary {
  background: var(--bg-elev-2);
  color: var(--fg);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: #20303a; }

.hint, .muted {
  margin: 10px 0 0;
  color: var(--fg-muted);
  font-size: 12.5px;
  text-align: center;
}
.muted { text-align: left; }
.disclaimer {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  font-size: 12px;
  color: var(--fg-dim);
  font-style: italic;
}

/* Result */
.result {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow-1);
  text-align: center;
  animation: fade-in 320ms ease;
}
.result h2 {
  margin: 0 0 8px;
  font-size: 22px;
}
.result.win h2 { color: #7fd29a; }
.result.lose h2 { color: #ee9087; }
.result-dx { font-size: 15px; color: var(--fg-muted); margin: 4px 0 12px; }
.result-dx strong { color: var(--fg); }
.result-teaching {
  background: var(--bg-elev-2);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.55;
  text-align: left;
  margin-bottom: 14px;
  color: var(--fg);
}
.result-share-grid {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}
.share-cell {
  width: 24px; height: 24px;
  border-radius: 4px;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.share-cell.win { background: var(--green); }
.share-cell.miss { background: #2f3d44; }
.share-cell.skip { background: var(--amber); }
.share-cell.empty { background: var(--bg-elev-2); border: 1px solid var(--border); }

/* Modals */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.65);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 100;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  animation: fade-in 180ms ease;
}
.modal.hidden { display: none; }
.modal-card {
  position: relative;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 460px;
  max-height: 88vh;
  overflow-y: auto;
  padding: 22px 20px;
}
.modal-card h2 { margin: 0 0 12px; font-size: 20px; }
.modal-card .subhead { font-size: 14px; color: var(--fg-muted); margin: 16px 0 8px; text-transform: uppercase; letter-spacing: 0.06em; }
.modal-close {
  position: absolute;
  top: 8px; right: 8px;
  width: 36px; height: 36px;
  border-color: transparent;
  font-size: 22px;
}
.help-list { padding-left: 22px; line-height: 1.6; }
.help-list li { margin-bottom: 8px; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}
.stat {
  display: flex; flex-direction: column;
  align-items: center;
  padding: 8px 4px;
  background: var(--bg-elev-2);
  border-radius: var(--radius-sm);
}
.stat-num { font-size: 22px; font-weight: 700; color: var(--fg); }
.stat-label { font-size: 11px; color: var(--fg-muted); margin-top: 2px; text-align: center; }

.hist { display: flex; flex-direction: column; gap: 6px; }
.hist-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px;
}
.hist-row .h-label { width: 18px; color: var(--fg-muted); text-align: right; }
.hist-row .h-bar {
  flex: 1;
  background: var(--bg-elev-2);
  border-radius: 4px;
  height: 22px;
  overflow: hidden;
  position: relative;
}
.hist-row .h-fill {
  background: var(--accent);
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding: 0 8px;
  color: #06181f;
  font-weight: 700;
  font-size: 12px;
  min-width: 22px;
  transition: width 280ms ease;
}
.hist-row.highlight .h-fill { background: var(--green); }

/* Footer */
.footer {
  margin-top: 24px;
  padding: 16px;
  text-align: center;
  font-size: 11px;
  color: var(--fg-dim);
  border-top: 1px solid var(--border);
}
.footer p { margin: 0; }

.hidden { display: none !important; }

/* Larger screens */
@media (min-width: 540px) {
  .brand { font-size: 24px; }
  .clue-list li { font-size: 16px; }
  .main { padding: 24px; gap: 20px; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* Light mode is unsupported by design — the medical-clinical dark theme is the brand. */
