:root {
  --ink: #f4efe0; --ink-dim: #c9d8cd; --panel: rgba(8, 36, 22, .78); --panel-edge: rgba(255, 255, 255, .16);
  --accent: #f2b632; --accent-ink: #2b1d00; --good: #7ed6a0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: #12452c url(../assets/backgrounds/table-green.svg) center / cover no-repeat;
  overflow: hidden; -webkit-tap-highlight-color: transparent;
}
app-view { display: block; height: 100dvh; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.screen { height: 100%; display: flex; flex-direction: column; min-height: 0; }

.btn {
  font: inherit; font-weight: 600; color: var(--ink); background: var(--panel); border: 1px solid var(--panel-edge);
  border-radius: 12px; padding: 10px 16px; min-height: 44px; cursor: pointer;
}
.btn:hover:not(:disabled) { border-color: var(--accent); }
.btn:focus-visible, .level-card:focus-visible, .tile:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn-big { font-size: 1.15rem; padding: 14px 24px; min-width: 220px; }

/* Menu and result */
.menu, .result { align-items: center; justify-content: safe center; text-align: center; padding: 24px 16px; gap: 6px; overflow-y: auto; }
.menu h1, .result h1 { font-size: clamp(2rem, 8vw, 3.4rem); margin: 0; letter-spacing: .02em; }
.menu-logo { font-size: clamp(3rem, 14vw, 5rem); line-height: 1; filter: drop-shadow(0 4px 6px rgba(0,0,0,.4)); }
.menu-tagline { margin: 0; color: var(--ink-dim); }
.menu-status { margin: 8px 0 14px; color: var(--ink-dim); font-size: .95rem; }
.menu-buttons { display: flex; flex-direction: column; gap: 12px; align-items: center; margin-top: 8px; }
.result-stats { display: grid; grid-template-columns: repeat(2, minmax(120px, 1fr)); gap: 10px; margin: 18px 0 6px; width: min(420px, 100%); }
.result-stats .stat { background: var(--panel); border: 1px solid var(--panel-edge); border-radius: 12px; padding: 10px; }

.stat { display: flex; flex-direction: column; align-items: center; line-height: 1.15; }
.stat span { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-dim); }
.stat strong { font-size: 1.15rem; font-variant-numeric: tabular-nums; }

/* Level select */
.levels { padding: 12px 16px 24px; overflow-y: auto; }
.screen-header { display: flex; align-items: center; gap: 12px; max-width: 960px; width: 100%; margin: 0 auto 12px; }
.screen-header h2 { margin: 0; }
.level-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(200px, 100%), 1fr)); gap: 14px; max-width: 960px; width: 100%; margin: 0 auto; }
.level-card {
  font: inherit; color: var(--ink); text-align: left; display: flex; flex-direction: column; gap: 4px;
  background: var(--panel); border: 1px solid var(--panel-edge); border-radius: 14px; padding: 12px; cursor: pointer;
}
.level-card:hover:not(:disabled) { border-color: var(--accent); }
.level-card.locked { opacity: .55; cursor: not-allowed; }
.level-card.done { border-color: var(--good); }
.level-preview { width: 100%; height: 90px; margin-bottom: 4px; }
.level-name { font-weight: 700; }
.level-meta { color: var(--accent); font-size: .85rem; }
.level-note { color: var(--ink-dim); font-size: .8rem; }

/* Game */
.hud {
  display: flex; align-items: center; gap: 8px; justify-content: space-between; padding: 8px 10px;
  background: var(--panel); border-bottom: 1px solid var(--panel-edge);
}
.hud .stat.level strong { max-width: 11ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 1rem; }
.hud .btn { padding: 8px 12px; }
.board-wrap { position: relative; flex: 1; min-height: 0; display: flex; }
.board { position: relative; flex: 1; min-height: 0; overflow: hidden; touch-action: manipulation; }
.board-stage { position: absolute; inset: 0; }
.tile {
  position: absolute; background-size: 100% 100%, 100% 100%; background-repeat: no-repeat; cursor: pointer;
  transition: opacity .22s, transform .22s, filter .15s, visibility 0s .22s;
  filter: brightness(.78) saturate(.8);
}
.tile.free { filter: none; }
.tile.selected { filter: drop-shadow(0 0 5px var(--accent)) brightness(1.08); transform: translateY(-3px); }
.tile.hint { animation: pulse .7s ease-in-out infinite alternate; filter: drop-shadow(0 0 6px #5ee1ff) brightness(1.1); }
.tile.removed { opacity: 0; transform: scale(.6); visibility: hidden; pointer-events: none; }
@keyframes pulse { to { transform: translateY(-4px) scale(1.04); } }
@media (prefers-reduced-motion: reduce) { .tile, .tile.hint { transition: none; animation: none; } }

.bar { display: flex; gap: 8px; padding: 8px 10px; background: var(--panel); border-top: 1px solid var(--panel-edge); }
.bar .action { flex: 1; padding: 10px 6px; }

.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, .5); z-index: 100000; padding: 16px; }
.dialog { background: #0f3a24; border: 1px solid var(--panel-edge); border-radius: 16px; padding: 20px; max-width: 360px; text-align: center; }
.dialog h2 { margin: 0 0 8px; }
.dialog p { color: var(--ink-dim); margin: 0 0 16px; }
.dialog-buttons { display: flex; gap: 10px; justify-content: center; }

@media (max-width: 480px) {
  .hud { gap: 4px; padding: 6px; }
  .hud .stat strong { font-size: 1rem; }
  .hud .stat span { font-size: .6rem; }
}

/* Short landscape phones: compact chrome so the board keeps most of the height. */
@media (max-height: 480px) {
  .hud { padding: 4px 8px; }
  .hud .btn, .bar .btn { min-height: 36px; padding: 4px 10px; }
  .bar { padding: 4px 8px; }
  .menu, .result { padding: 12px; }
  .menu-logo { font-size: 2.4rem; }
  .menu-buttons { flex-direction: row; flex-wrap: wrap; justify-content: center; }
}
@media (min-width: 900px) {
  .hud, .bar { padding-left: 16px; padding-right: 16px; }
}
