:root { color-scheme: dark; color: #f1f6ed; background: #101923; font: 16px/1.45 system-ui, sans-serif; }
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: radial-gradient(ellipse at top, #293f49, transparent 70%);
}
main { width: min(100%, 410px); }
h1 { margin: 0; font-size: clamp(2.7rem, 11vw, 4rem); letter-spacing: -.075em; line-height: 1; }
p { margin: 8px 0 14px; color: #c3d1d3; }
.controls { display: flex; gap: 8px; margin-bottom: 10px; }
.controls div, button { background: #263943; border-radius: 10px; }
.controls div { flex: 1; padding: 5px 10px; font-size: .875rem; }
strong { display: block; font-size: 1.25rem; font-variant-numeric: tabular-nums; }
button { min-height: 44px; padding: 8px 12px; border: 1px solid #536b74; color: inherit; font: inherit; font-weight: 650; cursor: pointer; }
button:focus-visible { outline: 2px solid #d8f68c; outline-offset: 3px; }
#board { display: grid; grid-template: repeat(4, 1fr) / repeat(4, 1fr); aspect-ratio: 1; gap: 7px; padding: 8px; background: #344d57; border-radius: 15px; touch-action: none; user-select: none; }
.tile { display: grid; place-items: center; border-radius: 8px; background: #ffc581; color: #172620; font-size: clamp(1rem, 6vw, 2rem); font-weight: 800; }
.tile[data-value="0"] { background: #223640; }
.tile[data-value="2"] { background: #e0eade; }
.tile[data-value="4"] { background: #badfd2; }
.tile[data-value="8"] { background: #91d2bb; }
.tile[data-value="16"] { background: #65c7a4; }
.tile[data-value="32"] { background: #83d79b; }
.tile[data-value="64"] { background: #b3e588; }
.tile[data-value="128"] { background: #d8f68c; }
.tile[data-value="256"] { background: #f4db80; }
#tilt { width: 100%; margin-top: 12px; background: #d8f68c; color: #172620; }
#result { color: #d8f68c; font-weight: 700; }
#lab-install-open { background: transparent; }
#lab-offline-status:empty { display: none; }
dialog { max-width: min(28rem, 90vw); border-radius: 12px; }
@media (orientation: landscape) and (max-height: 520px) {
  main { width: min(100%, 680px); display: grid; grid-template-columns: min(66dvh, 48%) 1fr; gap: 6px 16px; }
  #board { grid-area: 1 / 1 / span 8; align-self: center; }
  main > p, .controls, #tilt { margin: 0; }
  h1 { font-size: 2.5rem; }
}
