* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: linear-gradient(#e8f1f4, #cfe2e9);
  color: #3d5566;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.8s ease;
}
body.theme-dusk { background: linear-gradient(#ded6e6, #aebad4); color: #43405c; }
body.theme-lantern { background: linear-gradient(#2b3350, #1b2237); color: #dfe6f2; }

#app { display: flex; flex-direction: column; height: 100dvh; }

#hud { display: flex; align-items: center; gap: 8px; padding: 10px 14px; z-index: 5; }
#hud.hidden { visibility: hidden; }
.hud-text { font-size: 15px; font-weight: 600; opacity: 0.85; padding: 0 4px; white-space: nowrap; }
#level-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.spacer { flex: 1; }

.pill {
  border: none; border-radius: 999px; padding: 9px 14px;
  font-size: 14px; font-weight: 600; font-family: inherit;
  background: rgba(255, 255, 255, 0.65); color: inherit; cursor: pointer;
  backdrop-filter: blur(6px);
  box-shadow: 0 1px 4px rgba(40, 70, 90, 0.12);
  transition: transform 0.12s, background 0.2s;
  min-height: 40px; min-width: 40px;
}
.pill:hover { background: rgba(255, 255, 255, 0.85); transform: translateY(-1px); }
.pill:active { transform: scale(0.96); }
.pill:disabled { opacity: 0.35; cursor: default; transform: none; }
body.theme-lantern .pill { background: rgba(255, 255, 255, 0.14); box-shadow: none; }
body.theme-lantern .pill:hover { background: rgba(255, 255, 255, 0.24); }
.pill.big { padding: 12px 22px; font-size: 16px; }
.pill.primary { background: #7fb8a4; color: #fff; }
.pill.primary:hover { background: #6faa96; }

#board-wrap { flex: 1; position: relative; min-height: 0; }
#board { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

#hint {
  position: absolute; bottom: 16px; left: 50%; transform: translateX(-50%);
  max-width: min(88%, 460px); padding: 10px 18px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.72); backdrop-filter: blur(6px);
  font-size: 13.5px; font-weight: 600; text-align: center;
  box-shadow: 0 2px 10px rgba(40, 70, 90, 0.14);
  opacity: 1; transition: opacity 0.6s; pointer-events: none; z-index: 4;
}
#hint.hidden { opacity: 0; }
body.theme-lantern #hint { background: rgba(38, 48, 76, 0.85); }

.level-section {
  grid-column: 1 / -1; text-align: left; margin: 8px 0 0 2px;
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1.5px; opacity: 0.55;
}

.overlay {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  background: rgba(214, 230, 236, 0.55); backdrop-filter: blur(10px);
  overflow: auto; padding: 20px;
}
body.theme-lantern .overlay { background: rgba(18, 25, 44, 0.6); }
.overlay.hidden { display: none; }

.card {
  background: rgba(255, 255, 255, 0.85); border-radius: 24px; padding: 28px 30px;
  max-width: 560px; width: 100%;
  box-shadow: 0 12px 40px rgba(40, 70, 90, 0.18);
  text-align: center;
}
body.theme-lantern .card { background: rgba(38, 48, 76, 0.93); }
.card h1 { margin: 0 0 6px; font-size: 30px; font-weight: 700; letter-spacing: 0.5px; }
.card.small { max-width: 400px; }
.tagline { margin: 0 0 18px; opacity: 0.75; font-size: 14.5px; line-height: 1.5; }
.row { display: flex; gap: 10px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }

#theme-row { display: flex; gap: 8px; justify-content: center; margin-bottom: 18px; flex-wrap: wrap; }
.theme-chip { border: 2px solid transparent; }
.theme-chip.active { border-color: #7fb8a4; }
.theme-chip.locked { opacity: 0.45; cursor: default; }
.theme-chip.locked:hover { transform: none; }

#level-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
  gap: 10px; margin-bottom: 20px;
}
.level-btn {
  border: none; border-radius: 16px; height: 58px; padding: 0;
  font-size: 17px; font-weight: 700; font-family: inherit;
  background: rgba(120, 160, 180, 0.16); color: inherit; cursor: pointer; position: relative;
  transition: transform 0.12s, background 0.2s;
}
.level-btn:hover { background: rgba(120, 160, 180, 0.3); transform: translateY(-2px); }
.level-btn.done { background: rgba(127, 184, 164, 0.28); }
.level-btn .tick { position: absolute; top: 4px; right: 7px; font-size: 11px; color: #4e9c82; }
body.theme-lantern .level-btn { background: rgba(255, 255, 255, 0.1); }
body.theme-lantern .level-btn.done { background: rgba(127, 184, 164, 0.25); }
body.theme-lantern .level-btn .tick { color: #8fd4ba; }

#fleet h2 { font-size: 13px; text-transform: uppercase; letter-spacing: 1.5px; opacity: 0.6; margin: 0 0 8px; }
#fleet-row { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; min-height: 22px; }
#fleet-row svg { opacity: 0.75; }
.fleet-empty { font-size: 13px; opacity: 0.5; font-style: italic; }

@media (max-width: 520px) {
  .lvl-name, .btn-txt { display: none; }
  .hud-text { font-size: 14px; }
}

@media (max-width: 480px) {
  .card { padding: 20px 16px; }
  .card h1 { font-size: 24px; }
  #hud { padding: 8px 8px; }
  .pill { padding: 8px 11px; }
  #level-grid { grid-template-columns: repeat(auto-fill, minmax(50px, 1fr)); gap: 8px; }
  .level-btn { height: 50px; }
}
