/* Modern shell around the game canvas (UI restyle 2026-09-15). Element ids, data
   attributes and the fullscreen/canvas rules are the contract with app.js. */
:root {
  color-scheme: dark;
  --bg: #0a0f1c; --panel: #131c33; --panel-2: #0f1730; --line: #263252;
  --ink: #f3f0e6; --muted: #98a3bd; --yellow: #ffd23f; --green: #5ee27a; --blue: #4aa3ff;
  font-family: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg); color: var(--ink); font-size: 15px;
}
* { box-sizing: border-box; }
body {
  margin: 0; min-height: 100svh; display: grid; align-items: center;
  background: var(--bg) radial-gradient(circle, rgba(255,210,63,.10) 1.4px, transparent 2px) 0 0 / 32px 32px fixed;
}
main { width: min(1328px, 100%); margin: auto; padding: 18px 24px 28px; }
a { color: var(--yellow); }

/* header */
header { display: flex; align-items: center; gap: 18px; margin: 0 0 14px; min-height: 40px; }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; }
.brand img { width: 34px; height: 34px; filter: drop-shadow(0 2px 6px rgba(0,0,0,.5)); }
.wordmark { font-weight: 800; font-size: 18px; letter-spacing: .06em; color: var(--yellow); }
.wordmark span { color: var(--muted); font-size: 12px; letter-spacing: .05em; font-weight: 700; margin-left: 6px; }
.edition { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
header button { margin-left: auto; border: 1px solid var(--line); background: var(--panel); color: var(--ink); display: inline-flex; align-items: center; gap: 8px; }

/* buttons & inputs */
button {
  font: inherit; font-weight: 700; cursor: pointer; border: 1px solid var(--line); background: var(--panel);
  color: var(--ink); border-radius: 12px; padding: 10px 16px; white-space: nowrap; transition: background .15s, transform .1s, border-color .15s;
}
button:hover { background: #1b2646; border-color: #3a4a78; }
button:active { transform: translateY(1px); }
button:focus-visible, summary:focus-visible, input:focus-visible { outline: 2px solid var(--yellow); outline-offset: 3px; }
button:disabled { opacity: .35; cursor: default; }
button span { margin-left: 10px; opacity: .6; font-weight: 600; }
.primary { background: var(--green); color: #0a0f1c; border-color: var(--green); font-weight: 800; min-width: 120px; box-shadow: 0 4px 0 rgba(0,0,0,.35); }
.primary:hover { background: #79f090; border-color: #79f090; }
.primary span { color: #0a0f1c; opacity: .6; }
input[type=range] { accent-color: var(--yellow); width: 100%; cursor: pointer; min-width: 90px; }
input[type=checkbox] { accent-color: var(--green); width: 16px; height: 16px; }
output { color: var(--yellow); font-weight: 800; margin-left: 8px; font-variant-numeric: tabular-nums; }

/* cabinet */
#cabinet {
  background: #000; aspect-ratio: 16/9; display: grid; place-items: center; position: relative;
  border: 1px solid var(--line); border-radius: 16px; overflow: hidden;
  box-shadow: 0 30px 80px rgba(0,0,0,.6), 0 0 0 6px rgba(255,210,63,.05);
}
canvas { display: block; width: 100%; height: auto; aspect-ratio: 640/350; image-rendering: pixelated; outline: none; touch-action: none; }
canvas[data-graphics="hd"] { image-rendering: auto; }
#cabinet:fullscreen { height: 100vh; width: 100vw; display: flex; align-items: center; justify-content: center; border: 0; border-radius: 0; overflow: hidden; }
#cabinet:fullscreen canvas { width: min(100vw, calc(100vh * var(--board-ratio, 1.8286))); max-height: 100vh; }
#cabinet:fullscreen[data-fill="true"] canvas[data-graphics="hd"] { width: 100%; height: 100%; max-height: none; object-fit: cover; object-position: center; }
#cabinet:fullscreen[data-fill="true"] canvas[data-graphics="hd"][data-world="0"] { object-position: center top; }
#load-error { padding: 20px; color: #ff9c9c; }
#benchmark-notice { padding: 12px 16px; border: 1px solid #aaa029; background: #2c280b; color: #fff383; border-radius: 12px; margin: 0 0 12px; }

/* dock */
.dock {
  display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 16px; padding: 10px; border-radius: 16px; background: var(--panel); border: 1px solid var(--line);
}
.worlds, .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.worlds button { border-color: transparent; background: transparent; color: var(--muted); }
.worlds button.selected { background: var(--panel-2); border-color: var(--line); color: var(--ink); }
.world-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin: 0 9px 1px 0; box-shadow: 0 0 8px currentColor; }
.world-dot.forest { background: var(--green); color: var(--green); }
.world-dot.ocean { background: var(--blue); color: var(--blue); }
.statusbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 6px 2px; flex-wrap: wrap; }
#status { margin: 0; color: var(--ink); font-weight: 600; }
#progress { color: var(--muted); font-size: 13px; white-space: nowrap; }

/* panels */
.panel { margin-top: 12px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); padding: 0 16px; color: var(--muted); font-size: 14px; line-height: 1.7; }
.panel > summary { cursor: pointer; padding: 12px 0; font-weight: 800; color: var(--ink); list-style: none; display: flex; align-items: center; gap: 8px; }
.panel > summary::before { content: "▸"; color: var(--yellow); transition: transform .15s; }
.panel[open] > summary::before { transform: rotate(90deg); }
.panel > summary::-webkit-details-marker { display: none; }
.panel > :not(summary) { margin-bottom: 14px; }
.panel p { margin: 0 0 12px; }
.muted-panel { background: transparent; }
.settings-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; padding-bottom: 2px; }
.setting { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.setting label, .setting-title { font-weight: 800; color: var(--ink); font-size: 13px; letter-spacing: .04em; text-transform: uppercase; display: flex; align-items: center; }
.setting .hint { font-size: 12px; color: var(--muted); }
.setting button { align-self: flex-start; padding: 8px 14px; }
.toggles { justify-content: center; }
.toggles label { text-transform: none; letter-spacing: 0; font-size: 14px; font-weight: 700; gap: 10px; cursor: pointer; }
.toggles .hint { margin-left: auto; }

/* footer & performance */
footer { font-size: 13px; padding: 12px 6px 0; color: var(--muted); text-align: center; }
footer p { margin: 0; }
kbd { font: inherit; font-size: 12px; font-weight: 700; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-bottom-width: 3px; border-radius: 6px; padding: 1px 7px; }
footer span { padding: 0 6px; color: var(--line); }
#performance { padding: 0; color: var(--muted); font-size: 13px; }
#perf-summary { font-variant-numeric: tabular-nums; }
#perf-detail, #benchmark-result { white-space: pre-wrap; font: 12px/1.7 Consolas, monospace; color: #b4c5d6; }
#benchmark-result { margin-top: 12px; }
.perf-actions { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; margin-top: 10px; }
.perf-actions button { padding: 6px 10px; font-size: 13px; }

/* touch */
.touch-controls { display: none; }
@media (pointer: coarse) {
  .touch-controls { display: flex; flex-direction: column; align-items: center; gap: 6px; padding-top: 14px; }
  .touch-controls div { display: flex; gap: 6px; }
  .touch-controls button { font-size: 24px; width: 64px; height: 52px; touch-action: none; border-radius: 14px; }
}

@media (max-width: 800px) {
  body { align-items: start; }
  main { padding: 10px 12px 24px; }
  .edition { display: none; }
  header button { padding: 8px 12px; }
  .dock { justify-content: center; }
  .worlds button { padding: 8px 10px; font-size: 13px; }
  .settings-grid { grid-template-columns: 1fr 1fr; }
  .statusbar { justify-content: center; text-align: center; }
  #progress { width: 100%; text-align: center; }
}
@media (max-width: 520px) { .settings-grid { grid-template-columns: 1fr; } }
@media (min-width: 801px) { main { width: min(1540px, 100%, calc((100svh - 330px) * var(--board-ratio, 1.8286) + 48px)); min-width: 560px; } }
