/* HexBee — Mobile-first honeycomb puzzle */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0f0600;
  --surface:  #1e0c00;
  --card:     #2a1200;
  --amber:    #d4691e;
  --amber2:   #e07c28;
  --gold:     #FFD700;
  --gold2:    #e6a800;
  --green:    #2ecc71;
  --red:      #e74c3c;
  --blue:     #3498db;
  --text:     #fff7e8;
  --muted:    #a07040;
  --easy:     #27ae60;
  --med:      #e67e22;
  --hard:     #e74c3c;
  --radius:   14px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  overflow: hidden;
  touch-action: manipulation;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#app { height: 100dvh; position: relative; }

/* ── Screens ─────────────────────────────────────────────── */
.screen {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  transition: opacity .2s;
}
.hidden { display: none !important; }

/* ── HOME ────────────────────────────────────────────────── */
#screen-home {
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px 20px;
  background: radial-gradient(ellipse at 50% 30%, #2d1200 0%, #0f0600 70%);
}

.logo {
  font-size: 3rem;
  font-weight: 900;
  letter-spacing: -1px;
  text-align: center;
  line-height: 1;
}
.logo span { color: var(--gold); }
.logo small { display: block; font-size: 1rem; font-weight: 400; color: var(--muted); letter-spacing: 2px; text-transform: uppercase; }

.streak-badge {
  display: flex; align-items: center; gap: 10px;
  background: var(--card);
  border: 1px solid #5a2a00;
  border-radius: 999px;
  padding: 10px 24px;
  font-size: 1.1rem;
}
.streak-badge .flame { font-size: 1.6rem; }
#streak-val { font-size: 1.75rem; font-weight: 800; color: var(--gold); }
#solved-count { font-size: .85rem; color: var(--muted); }

.home-buttons { display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 340px; }

.home-btn {
  width: 100%;
  padding: 18px 24px;
  border-radius: var(--radius);
  border: none;
  cursor: pointer;
  font-size: 1.25rem;
  font-weight: 700;
  transition: transform .1s, filter .1s;
  display: flex; flex-direction: column; align-items: center;
  line-height: 1.3;
}
.home-btn:active { transform: scale(.96); filter: brightness(.85); }
.home-btn small { font-size: .85rem; font-weight: 400; opacity: .8; }

#btn-daily { background: linear-gradient(135deg, #1e6e40, #27ae60); color: #fff; }
#btn-campaign { background: linear-gradient(135deg, #b85a00, #e07c28); color: #fff; }
#btn-practice { background: linear-gradient(135deg, #3a2060, #7b4fc0); color: #fff; }

.practice-menu {
  display: none;
  flex-direction: row;
  gap: 10px;
  width: 100%;
  max-width: 340px;
}
.pr-btn {
  flex: 1; padding: 12px 8px; border-radius: 10px; border: none;
  font-size: .95rem; font-weight: 700; cursor: pointer;
  transition: transform .1s;
}
.pr-btn:active { transform: scale(.93); }
.pr-btn.easy { background: #27ae60; color: #fff; }
.pr-btn.med  { background: #e67e22; color: #fff; }
.pr-btn.hard { background: #e74c3c; color: #fff; }

/* ── LEVELS ──────────────────────────────────────────────── */
#screen-levels { background: var(--bg); }

.lvl-header {
  display: flex; align-items: center; gap: 12px;
  padding: 16px 16px 10px;
  flex-shrink: 0;
}
.lvl-header h2 { font-size: 1.4rem; color: var(--gold); flex: 1; }

#levels-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
  padding: 6px 12px 20px;
  overflow-y: auto;
  flex: 1;
  align-content: start;
}

.lv-tier-hdr {
  grid-column: 1 / -1;
  font-size: .75rem; font-weight: 800;
  letter-spacing: 1.5px; text-transform: uppercase;
  padding: 10px 2px 5px;
  border-bottom: 1px solid #3a1800;
  margin-top: 4px;
}
.lv-tier-hdr:first-child { margin-top: 0; padding-top: 4px; }
.lv-tier-hdr--easy { color: var(--easy); }
.lv-tier-hdr--med  { color: var(--med);  }
.lv-tier-hdr--hard { color: var(--hard); }

.lv-btn {
  background: var(--card);
  border: 1px solid #3a1800;
  border-radius: 8px;
  padding: 7px 4px;
  cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  transition: transform .1s, background .15s;
  color: var(--text);
  min-width: 0;
}
.lv-btn:not(.locked):active { transform: scale(.92); background: #3a1800; }
.lv-btn.locked { opacity: .35; cursor: default; }

.lv-num { font-size: 1rem; font-weight: 800; }
.lv-stars { font-size: .65rem; color: var(--gold); min-height: 12px; }

/* ── GAME ────────────────────────────────────────────────── */
#screen-game { background: var(--surface); }

.game-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  background: var(--card);
  flex-shrink: 0;
  border-bottom: 1px solid #3a1800;
}
#level-title { flex: 1; font-weight: 700; font-size: 1.05rem; color: var(--gold); }
#timer { font-variant-numeric: tabular-nums; font-size: 1rem; color: var(--muted); }

.icon-btn {
  background: none; border: none; cursor: pointer;
  font-size: 1.6rem; padding: 5px 8px; color: var(--text);
  border-radius: 8px; transition: background .15s;
  display: flex; align-items: center; gap: 3px;
  position: relative;
}
.icon-btn:active { background: rgba(255,255,255,.1); }
.icon-btn:disabled { opacity: .3; cursor: default; }
.hint-badge {
  position: absolute; top: -2px; right: -2px;
  background: var(--gold); color: #000;
  font-size: .65rem; font-weight: 800;
  border-radius: 99px; padding: 1px 4px; min-width: 16px; text-align: center;
}

#game-container {
  flex: 1; display: flex; align-items: center; justify-content: center;
  overflow: hidden; padding: 6px;
  touch-action: none;
}

#hex-grid {
  width: 100%; height: 100%;
  max-width: 520px; max-height: calc(100dvh - 130px);
  display: block;
  touch-action: none;
}

/* ── Hex polygon base ────────────────────────────────────── */
.hpoly {
  fill: var(--amber);
  stroke: #7a3200;
  stroke-width: 1.5;
  transition: fill .18s ease;
}
.htext {
  fill: #fff;
  font-weight: 800;
  font-family: 'Segoe UI', system-ui, sans-serif;
  pointer-events: none;
}
.hlabel-start {
  fill: #7fffb8;
  font-weight: 800;
  font-family: 'Segoe UI', system-ui, sans-serif;
  pointer-events: none;
  letter-spacing: .5px;
}
.hlabel-end {
  fill: #ff9090;
  font-weight: 800;
  font-family: 'Segoe UI', system-ui, sans-serif;
  pointer-events: none;
  letter-spacing: .5px;
}

/* ── START / FINISH markers ──────────────────────────────── */
.pentry {
  stroke: #2ecc71;
  stroke-width: 3;
  filter: url(#glow-s);
  animation: pulse-entry 1.4s ease-in-out infinite;
}
.pgoal {
  stroke: #e74c3c;
  stroke-width: 3;
  filter: url(#glow-s);
}

@keyframes pulse-entry {
  0%,100% { stroke-opacity: 1; stroke-width: 3; }
  50%      { stroke-opacity: .4; stroke-width: 2; }
}

/* ── Visited / state classes ─────────────────────────────── */
.pdone  { fill: url(#gDone); stroke: #a07000; }
.plast  { fill: url(#gLast); stroke: #1a7040; }
.pdead  { fill: #2a0a0a; stroke: #5a1a1a; }

.pcorrect { animation: flash-correct .35s ease forwards; }
.pwrong   { animation: flash-wrong .35s ease forwards; }
.phint    { animation: hint-pulse 1.8s ease forwards; }
.pundo    { animation: flash-undo .4s ease forwards; }

@keyframes flash-correct {
  0%   { fill: #7fff9f; stroke: #2ecc71; }
  100% { fill: url(#gDone); }
}
@keyframes flash-wrong {
  0%,100% { fill: var(--amber); }
  50%      { fill: #e74c3c; stroke: #c0392b; }
}
@keyframes hint-pulse {
  0%,100% { fill: var(--amber); }
  20%,70% { fill: #2980b9; stroke: var(--blue); }
}
@keyframes flash-undo {
  0%   { fill: #e8c0ff; stroke: #9b59b6; }
  100% { fill: var(--amber); }
}

.game-footer {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 16px;
  background: var(--card);
  flex-shrink: 0;
  border-top: 1px solid #3a1800;
}
.progress-bar {
  flex: 1; height: 10px; background: #3a1800; border-radius: 99px; overflow: hidden;
}
.progress-fill {
  height: 100%; background: linear-gradient(90deg, var(--amber), var(--gold));
  border-radius: 99px; transition: width .25s ease; width: 0%;
}
#progress-num { font-size: .9rem; color: var(--muted); min-width: 58px; text-align: right; }

/* ── WIN ─────────────────────────────────────────────────── */
#screen-win {
  align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, #1e0c00 0%, #0f0600 100%);
  padding: 20px;
}
.win-card {
  background: var(--card);
  border: 1px solid #5a2a00;
  border-radius: 20px;
  padding: 32px 28px;
  max-width: 340px; width: 100%;
  text-align: center;
  display: flex; flex-direction: column; gap: 14px;
}
.win-trophy { font-size: 4rem; line-height: 1; }
#win-title  { font-size: 1.5rem; font-weight: 800; color: var(--gold); }
#win-stars  { font-size: 2.3rem; letter-spacing: 4px; color: var(--gold); }
.win-time   { color: var(--muted); font-size: 1.05rem; }
.win-time span { color: var(--text); font-weight: 700; font-size: 1.25rem; }
#win-streak { font-size: 1.1rem; font-weight: 700; color: var(--gold); }
.win-btns   { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.win-btn {
  padding: 16px; border-radius: 12px; border: none;
  font-size: 1.1rem; font-weight: 700; cursor: pointer;
  transition: transform .1s, filter .1s;
}
.win-btn:active { transform: scale(.95); filter: brightness(.85); }
.win-btn.primary { background: linear-gradient(135deg, #b85a00, #e07c28); color: #fff; }
.win-btn.secondary { background: var(--surface); color: var(--text); border: 1px solid #3a1800; }
.win-btn.share { background: linear-gradient(135deg, #1a4060, #2980b9); color: #fff; }

/* ── HOME footer ─────────────────────────────────────────── */
.home-footer {
  margin-top: auto;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  text-align: center;
}
.home-footer p { font-size: .7rem; color: var(--muted); }
.about-link-btn {
  background: none; border: none;
  font-size: .72rem; color: var(--muted);
  cursor: pointer; padding: 3px 10px;
  border-radius: 6px;
  text-decoration: underline; text-underline-offset: 2px;
  transition: color .15s;
}
.about-link-btn:active { color: var(--text); }

.install-btn {
  background: none;
  border: 1px solid #5a2a00;
  color: var(--amber2);
  font-size: .78rem; font-weight: 600;
  padding: 7px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.install-btn:active { background: var(--card); }

.ios-tip {
  font-size: .75rem; color: var(--text);
  background: var(--card);
  border: 1px solid #5a2a00;
  border-radius: 10px;
  padding: 8px 14px;
  text-align: center;
  line-height: 1.5;
  max-width: 240px;
}
.ios-tip strong { color: var(--gold); }

/* ── ABOUT ───────────────────────────────────────────────── */
#screen-about { background: var(--bg); }

.about-body {
  flex: 1; overflow-y: auto;
  padding: 20px 28px 40px;
  display: flex; flex-direction: column; align-items: center;
  text-align: center; gap: 10px;
}

.about-logo { font-size: 3.5rem; line-height: 1; }
.about-title { font-size: 1.8rem; font-weight: 800; color: var(--gold); }
.about-sub {
  font-size: .8rem; letter-spacing: 2px;
  text-transform: uppercase; color: var(--muted);
}
.about-divider {
  width: 48px; height: 1px;
  background: #3a1800; margin: 6px 0;
}
.about-label {
  font-size: .68rem; font-weight: 800;
  letter-spacing: 1.5px; text-transform: uppercase;
  color: var(--muted); margin-top: 4px;
}
.about-text {
  font-size: .95rem; line-height: 1.6;
  color: var(--text); max-width: 300px;
}
.about-text strong { color: var(--gold); }
.about-link { color: var(--amber2); text-decoration: none; font-weight: 700; }
.about-link:active { text-decoration: underline; }
.about-privacy {
  font-size: .78rem; line-height: 1.65;
  color: var(--muted); max-width: 280px;
}

/* ── Shared back button ──────────────────────────────────── */
.back-btn {
  background: none; border: none; color: var(--muted);
  font-size: 1.6rem; cursor: pointer; padding: 5px 10px;
  border-radius: 8px; transition: color .15s;
}
.back-btn:active { color: var(--text); }

/* ── Confetti canvas ─────────────────────────────────────── */
#confetti-canvas {
  position: fixed; inset: 0;
  pointer-events: none;
  z-index: 999;
  display: none;
}

/* ── Scrollbar (levels) ───────────────────────────────────── */
#levels-grid::-webkit-scrollbar { width: 4px; }
#levels-grid::-webkit-scrollbar-thumb { background: #3a1800; border-radius: 2px; }

/* ── Safe areas (iPhone notch etc.) ──────────────────────── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
  .game-footer, #screen-home, .win-card { padding-bottom: max(8px, env(safe-area-inset-bottom)); }
}

@media (min-width: 480px) {
  #screen-home { gap: 24px; }
  .home-btn { font-size: 1.35rem; }
}
