:root {
  --bg: #000000;
  --panel: #0d0d0d;
  --text: #f2f2f2;
  --muted: #a0a0a0;
  --accent: #ff8a5c; /* warm orange */
  --accent-2: #ffb36b; /* softer amber for gradient blend */
  --danger: #ff6b6b;
  --ok: #47d16c;
  --brand: #e86c56;
  --ring: #333333;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: radial-gradient(900px 600px at 30% -10%, #151515 0%, #000 55%);
  color: var(--text);
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 28px 20px 44px;
  display: grid;
  gap: 20px;
}

.header h1 {
  margin: 0 0 6px 0;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.brand { display: flex; align-items: center; gap: 8px; }
.brand-text { color: var(--accent); letter-spacing: 1px; font-weight: 600; }
.brand-icon { display: inline-block; position: relative; top: 1px; }
.brand-outline { stroke: var(--text); stroke-width: 2.5px; }
.brand-wedge { fill: var(--accent); }


.subtitle {
  margin: 0;
  color: var(--muted);
}

.header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.header .title { flex: 1; }

.header-actions { display: flex; gap: 8px; }

.pill {
  height: 36px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid #222222;
  background: #111111;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.btn-icon svg { fill: none; stroke: var(--accent); stroke-width: 1.6px; }
.btn-icon svg rect { fill: var(--accent); stroke: none; }

.game-card {
  display: grid;
  gap: 12px;
  padding: 16px;
  background: rgba(16,16,16,0.65);
  border: 1px solid #1a1a1a;
  border-radius: 22px;
  box-shadow: 0 24px 48px rgba(0,0,0,0.5);
}

.board {
  display: grid;
  place-items: center;
  padding: 20px;
  background: linear-gradient(180deg, #131313, #0d0d0d);
  border: 1px solid #1a1a1a;
  border-radius: 20px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.45);
  position: relative;
}

/* Make the SVG responsive */
.board svg { width: 320px; max-width: 100%; height: auto; }

.base-circle {
  fill: #000000;
  stroke: #2a2a2a;
  stroke-width: 2;
}

.ring {
  fill: none;
  stroke: var(--ring);
  stroke-width: 3;
}

/* Hide any apex markers (we don't draw any explicit ones, but keep rule here) */
.sector-apex { display: none; }

.sector {
  fill: url(#sector-gradient);
}

/* Inject gradient via JS; fallback solid */
svg .sector {
  fill: var(--accent);
}

/* Cute buttons/toggles */
.pill, button {
  transition: transform 0.05s ease-in-out, background 0.2s, border-color 0.2s;
}
.pill:hover, button:hover { transform: translateY(-1px); }
.pill:active, button:active { transform: translateY(0); }

.controls {
  display: grid;
  gap: 12px;
}

.control-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
}

.guess-input {
  height: 44px;
  padding: 0 12px;
  border-radius: 10px;
  background: #0d0d0d;
  border: 1px solid #222222;
  color: var(--text);
  font-size: 16px;
}

button {
  height: 44px;
  padding: 0 14px;
  border-radius: 10px;
  border: 1px solid #222222;
  color: var(--text);
  background: #111111;
  cursor: pointer;
  transition: transform 0.02s ease-in-out, background 0.2s;
}

button:active {
  transform: translateY(1px);
}

button.primary {
  background: #1a1a1a;
  border-color: #333333;
}

button.ghost {
  background: transparent;
}

.feedback {
  min-height: 24px;
  color: var(--muted);
}

.feedback strong {
  color: var(--text);
}

.feedback.good { color: var(--ok); }
.feedback.bad { color: var(--danger); }

/* Celebration overlay */
.confetti-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  width: 8px;
  height: 14px;
  border-radius: 2px;
  opacity: 0.95;
}

/* Sector pop */
.sector-pop {
  animation: pop 450ms ease-out;
  transform-origin: 150px 150px;
}

@keyframes pop {
  0% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(255,255,255,0)); }
  30% { transform: scale(1.05); filter: drop-shadow(0 6px 18px rgba(110,168,254,0.5)); }
  100% { transform: scale(1); filter: drop-shadow(0 0 0 rgba(255,255,255,0)); }
}

.attempts {
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px dashed #1a1a1a;
}

.attempts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  margin-bottom: 6px;
}

.attempts-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.attempt-item {
  display: grid;
  grid-template-columns: 32px 68px 1fr 18px 76px 12px; /* index | value | spacer | temp emoji | label (badge) | arrow */
  gap: 4px;
  align-items: center;
  padding: 8px 12px;
  height: 42px;
  background: #0e0e0e;
  border: 1px solid #1c1c1c;
  border-radius: 12px;
}

.attempt-index {
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: #151515;
  color: var(--muted);
  font-size: 12px;
}

.attempt-guess { color: var(--text); width: 68px; text-align: left; font-variant-numeric: tabular-nums; font-feature-settings: 'tnum' 1; }
.attempt-diff { color: var(--muted); }

.attempt-hint { 
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  text-align: center;
  width: 100%;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
}
.attempt-hint.hint-cold { background: rgba(110,168,254,0.12); color: #6ea8fe; }
.attempt-hint.hint-freezing { background: rgba(80,130,220,0.14); color: #6aa0ff; }
.attempt-hint.hint-warm { background: rgba(255,207,102,0.12); color: #ffcf66; }
.attempt-hint.hint-hot { background: rgba(255,138,92,0.12); color: #ff8a5c; }
.attempt-hint.hint-boiling { background: rgba(255,77,77,0.12); color: #ff4d4d; }
.attempt-hint.hint-perfect { background: transparent; color: var(--ok); padding: 0; letter-spacing: 2px; }

.temp-emoji { width: 18px; display: grid; place-items: center; line-height: 1; font-size: 16px; }
.attempt-emoji { width: 12px; display: grid; place-items: center; line-height: 1; font-size: 11px; opacity: 0.85; }
.attempt-emoji::before { display: block; width: 12px; text-align: center; }

/* Subtle hover polish */
.attempt-item:hover {
  background: #111111;
  border-color: #272727;
}

/* Inline tip under the board */
.tip { color: var(--muted); font-size: 13px; margin: 2px 2px 0; }
.tip .tip-colored { color: var(--accent); }
.bubble {
  position: absolute;
  left: 12px;
  top: 12px;
  padding: 8px 12px;
  background: #101010;
  border: 1px solid #232323;
  color: var(--text);
  border-radius: 10px;
  font-size: 12px;
  box-shadow: 0 10px 20px rgba(0,0,0,0.4);
  opacity: 1;
  transition: opacity 200ms ease;
}
.bubble.hide { opacity: 0; pointer-events: none; }
.bubble .accent { color: var(--accent); font-weight: 600; }
.bubble:after,
.bubble:before {
  content: '';
  position: absolute;
  right: 18px;
  bottom: -8px;
  width: 0; height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
}
.bubble:after { border-top: 8px solid #232323; }
.bubble:before { bottom: -7px; border-top: 7px solid #101010; right: 19px; }
.mode-toggle { color: var(--muted); font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }

/* Footer */
.footer { display:flex; justify-content:center; gap:12px; color: var(--muted); font-size:13px; padding: 8px 0 12px; }
.footer.fixed { position: fixed; left: 0; right: 0; bottom: 8px; padding: 6px 0; z-index: 10; }

/* Link colors: always on-brand orange */
a { color: var(--accent); }
a:visited { color: var(--accent); }
a:hover { color: var(--accent-2); }
.footer a { text-decoration: none; border-bottom: 1px dotted #444; }

/* Toast */
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 72px; background: rgba(20,20,20,0.95); border: 1px solid #2a2a2a; color: var(--text); padding: 10px 14px; border-radius: 10px; box-shadow: 0 10px 30px rgba(0,0,0,0.4); z-index: 20; }
.toast.show { animation: toastIn 200ms ease-out, toastOut 200ms ease-in 2400ms forwards; }
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes toastOut { to { opacity: 0; transform: translate(-50%, 6px); } }

.hint-cold { color: #5bb0ff; }
.hint-warm { color: #ffcf66; }
.hint-hot { color: #ff8a5c; }
.hint-boiling { color: #ff4d4d; }
.hint-perfect { color: var(--ok); }

.attempt-emoji.arrow-up::before { content: "▲"; color: var(--ok); }
.attempt-emoji.arrow-down::before { content: "▼"; color: var(--danger); }
.attempt-emoji.perfect-icon::before { content: "🎉"; }

@media (max-width: 480px) {
  .app { padding: 16px 12px 64px; }
  .board { padding: 12px; }
  .board svg { width: min(92vw, 360px); }
  .control-row { grid-template-columns: 1fr auto; grid-auto-rows: 44px; }
  .guess-input { font-size: 16px; } /* prevent iOS zoom */
  .attempt-item { grid-template-columns: 28px 56px 1fr 16px 72px 12px; gap: 4px; height: 40px; }
  .attempt-index { width: 22px; height: 22px; font-size: 11px; }
  .attempt-emoji { width: 16px; font-size: 13px; }
  .footer.fixed { bottom: max(8px, env(safe-area-inset-bottom)); }
  /* Prevent header pills from wrapping; hide icons to save space */
  .pill { white-space: nowrap; font-size: 13px; padding: 0 10px; }
  .btn-icon { display: none; }
}

/* Modal */
.modal[hidden] { display: none !important; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(2px);
}

.modal-card {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(440px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  background: #0e0e0e;
  border: 1px solid #1f1f1f;
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.4);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px 10px;
  border-bottom: 1px solid #222222;
}

.modal-body {
  padding: 16px;
  color: var(--text);
}

.modal-close { background: transparent; border: none; color: var(--text); font-size: 18px; }

.stats-summary { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.stats-summary .stat { background: #111111; border: 1px solid #222222; border-radius: 10px; padding: 10px; text-align: center; }
.stats-summary .stat .label { color: var(--muted); font-size: 12px; }
.stats-summary .stat .value { font-size: 20px; font-weight: 700; }

.stats-dist { margin-top: 12px; display: grid; gap: 8px; }
.dist-row { display: grid; grid-template-columns: 32px 1fr 40px; gap: 8px; align-items: center; }
.dist-bar { height: 12px; background: #1b1b1b; border-radius: 999px; position: relative; overflow: hidden; }
.dist-bar > span { position: absolute; left: 0; top: 0; bottom: 0; background: #6ea8fe; }

.share-text { padding: 10px; background: #0e0e0e; border: 1px solid #1c1c1c; border-radius: 10px; white-space: pre-wrap; }
.share-actions { display: flex; gap: 8px; margin-top: 10px; }


