:root {
  --felt: #1f5a2e; --felt-2: #123a1c; --bar: #0f2a16; --bar-line: #24452b; --ink: #f1f7ec; --muted: #a9c3a0;
  --accent: #6cc417; --heart: #e23b4a; --gold: #ffd84d;
  --tile-face: #fbf7ea; --tile-face-2: #eee5cc; --tile-edge-1: #8fd14a; --tile-edge-2: #4c8c1b;
  --font: "Trebuchet MS", "Segoe UI", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--felt-2); color: var(--ink); font-family: var(--font);
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
#app { height: 100%; display: flex; flex-direction: column; }
.hud, .bar { background: var(--bar); display: flex; align-items: center; gap: 8px; padding: 5px 10px; flex: none; }
.hud { border-bottom: 1px solid var(--bar-line); justify-content: space-between; }
.bar { border-top: 1px solid var(--bar-line); justify-content: space-between; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 6px; font-size: 17px; white-space: nowrap; }
.brand img { width: 28px; height: 28px; }
.brand b { color: var(--heart); }
.stats { display: flex; gap: 2px; }
.stat { display: flex; flex-direction: column; align-items: flex-end; padding: 0 8px; min-width: 52px; }
.stat + .stat { border-left: 1px solid var(--bar-line); }
.stat b { font-size: 18px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat small { font-size: 10px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
#combo.hot { color: var(--gold); }
.felt { flex: 1; min-height: 0; position: relative; background: radial-gradient(ellipse at 50% 40%, var(--felt), var(--felt-2)); display: grid; place-items: center; overflow: hidden; }
.board-box { position: relative; }
.board { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.tile { position: absolute; width: 46px; height: 60px; border-radius: 7px; cursor: pointer; border: 0; padding: 0; background: var(--tile-face);
  box-shadow: 1px 1px 0 var(--tile-edge-1), 2px 2px 0 var(--tile-edge-1), 3px 3px 0 var(--tile-edge-2), 4px 4px 0 var(--tile-edge-2), 6px 7px 8px rgba(0,0,0,.4);
  transition: transform .12s ease, opacity .25s ease; }
.tile .face { position: absolute; inset: 0; border-radius: 7px; background: linear-gradient(150deg, var(--tile-face), var(--tile-face-2)); overflow: hidden; }
.tile svg { width: 100%; height: 100%; display: block; pointer-events: none; }
.tile.sel .face { background: linear-gradient(150deg, #e9ffcf, #bfeb8f); }
.tile.sel { transform: translate(-1px, -2px); }
.tile.hint .face { animation: hint .5s ease-in-out 3 alternate; }
@keyframes hint { to { background: linear-gradient(150deg, #fff3b0, #ffd84d); } }
.tile.nope { animation: nope .25s; }
@keyframes nope { 25% { transform: translateX(-3px); } 75% { transform: translateX(3px); } }
.tile.gone { opacity: 0; transform: scale(.8) translateY(-8px); pointer-events: none; }
.tile:focus { outline: none; }
.tile:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.pop { position: absolute; font-weight: 800; font-size: 18px; color: var(--gold); text-shadow: 0 2px 0 #7a4b00; pointer-events: none; animation: pop .9s ease-out forwards; z-index: 99999; }
@keyframes pop { to { transform: translateY(-34px); opacity: 0; } }
button { font: inherit; }
.modes { display: flex; background: var(--felt-2); border: 1px solid var(--bar-line); border-radius: 999px; padding: 2px; }
.modes button { border: 0; background: transparent; color: var(--muted); font-size: 13px; font-weight: 700; padding: 5px 11px; border-radius: 999px; cursor: pointer; }
.modes button[aria-pressed="true"] { background: var(--accent); color: #0f2a16; }
.actions { display: flex; gap: 6px; }
.actions button { border: 1px solid var(--bar-line); background: var(--felt-2); color: var(--ink); border-radius: 8px; padding: 5px 10px; cursor: pointer; font-size: 13px; font-weight: 700; }
.actions button:hover, .modes button:hover { border-color: var(--accent); }
.actions em { font-style: normal; color: var(--muted); font-size: 11px; }
.overlay[hidden] { display: none; }
.overlay { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(6, 20, 10, .66); z-index: 100000; padding: 12px; }
.panel { background: #fbfdf8; color: #1d2918; border-radius: 14px; padding: 18px 20px; max-width: 340px; width: 100%; text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.45); max-height: 100%; overflow: auto; }
.panel img { width: 56px; height: 56px; }
.panel h2 { font-size: 24px; line-height: 1.1; margin: 4px 0 6px; }
.panel .big { font-size: 40px; font-weight: 800; color: #2d7409; font-variant-numeric: tabular-nums; margin: 4px 0; }
.panel p { margin: 4px 0; color: #5a6951; font-size: 14px; line-height: 1.4; }
.panel .rows { text-align: left; margin: 8px 0; font-size: 14px; display: grid; gap: 2px; font-variant-numeric: tabular-nums; }
.panel .rows div { display: flex; justify-content: space-between; gap: 12px; }
.panel .go { margin-top: 10px; font-size: 16px; font-weight: 800; background: #4fae1d; color: #fff; border: 0; border-radius: 9px; padding: 9px 22px; cursor: pointer; }
.panel .ghost { margin-top: 10px; margin-left: 6px; font-size: 14px; font-weight: 700; background: transparent; color: #2d7409; border: 1px solid #cfe0c4; border-radius: 9px; padding: 8px 14px; cursor: pointer; }
.panel .note { font-size: 12px; color: #2d7409; }
@media (max-width: 560px) {
  .brand span { display: none; }
  .stat { min-width: 0; padding: 0 6px; } .stat b { font-size: 15px; } .stat small { font-size: 9px; }
  .actions button, .modes button { padding: 4px 8px; font-size: 12px; }
  .actions em { display: none; }
}
@media (max-height: 360px) {
  .hud, .bar { padding: 3px 8px; } .stat small { display: none; }
  .panel { padding: 10px 14px; } .panel img, .panel .extra { display: none; } .panel h2 { font-size: 18px; margin: 0 0 2px; }
  .panel p { font-size: 12px; margin: 2px 0; } .panel .big { font-size: 28px; } .panel .rows { font-size: 12px; margin: 4px 0; }
  .panel .go, .panel .ghost { margin-top: 6px; padding: 6px 14px; font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) { .tile, .tile.hint .face, .pop, .tile.nope { animation: none !important; transition: none !important; } }
