:root {
  color-scheme: dark;
  --background: #101a23;
  --panel: #182734;
  --board: #12212d;
  --line: #354856;
  --text: #f5f0e8;
  --muted: #b7c4ce;
  --accent: #efae6d;
  --accent-hover: #ffc891;
  --focus: #b7e0dc;
  font-family: system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; background: radial-gradient(ellipse at 45% 10%, #203143 0, var(--background) 64%); color: var(--text); }
button, input { font: inherit; }
button { color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
a { color: var(--accent); text-underline-offset: .23em; }
.shell { max-width: 1370px; margin-inline: auto; padding-inline: clamp(15px, 3.5vw, 46px); }
.masthead { background: #14222f; border-bottom: 1px solid var(--line); }
.masthead-inner { min-height: 72px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.identity, .player-tools { display: flex; align-items: center; gap: 12px; }
.mark { display: grid; place-items: center; width: 38px; height: 38px; color: #202633; background: var(--accent); font-size: 23px; }
h1, h2, h3, p { margin: 0; }
h1, .round-title h2, .dialog-head h2 { font-family: Georgia, serif; font-weight: 500; letter-spacing: -.045em; }
h1 { font-size: clamp(1.65rem, 3.1vw, 2.55rem); white-space: nowrap; }
h1 em { color: var(--accent); font-weight: 400; }
.head-action, .footer button { border: 0; background: transparent; padding: 7px 5px; font-size: .91rem; }
.head-action:hover, .footer button:hover { color: var(--accent-hover); }
.points { font-variant-numeric: tabular-nums; display: inline-block; min-width: 28px; margin-left: 4px; padding: 2px 4px; background: #293b4a; color: var(--accent-hover); }
.game-bar { display: flex; align-items: end; gap: clamp(12px, 2vw, 28px); margin-block: clamp(16px, 2.3vw, 28px) 18px; }
.round-title { flex: 1; min-width: 0; }
.category { color: var(--accent); font-size: .77rem; font-weight: 650; letter-spacing: .12em; text-transform: uppercase; margin-bottom: 3px; }
.round-title h2 { font-size: clamp(1.9rem, 3.6vw, 3.1rem); line-height: 1.05; overflow-wrap: anywhere; }
.difficulty { position: relative; display: flex; margin: 0; padding: 0; border: 0; min-width: 0; }
.difficulty legend { padding: 0 0 4px; color: var(--muted); font-size: .84rem; }
.difficulty label { position: relative; cursor: pointer; }
.difficulty input { position: absolute; opacity: 0; pointer-events: none; }
.difficulty span { min-width: 41px; height: 42px; display: grid; place-items: center; background: var(--panel); border: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.difficulty label + label span { border-left: 0; }
.difficulty input:checked + span { color: #25232a; background: var(--accent); border-color: var(--accent); font-weight: 700; }
.difficulty input:focus-visible + span { outline: 2px solid var(--focus); outline-offset: 3px; position: relative; z-index: 1; }
.button { border: 1px solid #4a5e6e; background: #233544; min-height: 42px; padding: 7px 13px; font-size: .88rem; white-space: nowrap; }
.button:hover:not(:disabled) { background: #314858; }
.button.primary { background: var(--accent); border-color: var(--accent); color: #262026; font-weight: 750; }
.button.primary:hover:not(:disabled) { background: var(--accent-hover); }
.button.subtle { background: transparent; border-color: transparent; color: var(--muted); }
.button.compact { min-height: 34px; padding: 4px 10px; }
.play-area { display: grid; grid-template-columns: minmax(0, 1.38fr) minmax(0, 1fr); align-items: stretch; gap: 15px; }
.workbench { background: var(--panel); border: 1px solid var(--line); display: flex; flex-direction: column; min-width: 0; }
.panel-head { padding: 10px 15px; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 54px; }
.panel-head h3 { font-size: 1rem; font-weight: 650; }
.stats { display: flex; gap: 15px; align-items: center; color: var(--muted); font-size: .9rem; font-variant-numeric: tabular-nums; }
.stats b { color: var(--accent-hover); }
#clock { color: var(--text); }
.board { position: relative; margin-inline: 13px; aspect-ratio: 5 / 4; background-color: var(--board); border: 1px solid #526575; isolation: isolate; }
.guide, .grid, .placed { position: absolute; inset: 0; }
.guide { background: radial-gradient(ellipse, #203445 0, #162636 70%); }
.grid { display: grid; grid-template-columns: repeat(var(--n, 6), 1fr); grid-template-rows: repeat(var(--n, 6), 1fr); touch-action: manipulation; }
.cell { padding: 0; min-height: 0; min-width: 0; border: 0; border-right: 1px solid #adc2d01a; border-bottom: 1px solid #adc2d01a; background: transparent; }
.grid.ready .cell:not(.filled):hover { background: #e0c29625; }
.grid .cell.wrong { background: #ed8c7144; }
.cell:focus-visible { outline-offset: -2px; position: relative; z-index: 3; }
.placed { pointer-events: none; }
.placed canvas { position: absolute; }
.watermark { pointer-events: none; position: absolute; z-index: 3; right: 9px; bottom: 8px; background: #14222fbd; color: #fff4e4; font-size: .75rem; letter-spacing: .06em; padding: 3px 7px; }
.veil { position: absolute; inset: 0; z-index: 5; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; background: #13232dec; font-size: 1.15rem; }
.controls { display: flex; flex-wrap: wrap; gap: 7px; margin: 12px 13px; }
.controls .subtle { margin-left: auto; }
.tray-panel { position: relative; }
.remaining { color: var(--muted); font-size: .84rem; font-weight: 400; margin-left: 5px; }
.tray-filters { display: flex; gap: 3px; padding: 0 13px 8px; }
.filter { padding: 5px 10px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font-size: .88rem; }
.filter[aria-pressed="true"] { color: var(--accent-hover); border-color: var(--accent); }
.tray { position: relative; flex: 1; margin-inline: 13px; min-height: 0; overflow: auto; background: #101d28; border: 1px solid #3c5161; padding: 7px; display: grid; grid-template-columns: repeat(var(--tray-cols, 6), minmax(0, 1fr)); align-content: start; gap: 3px; scrollbar-color: #617482 #152433; }
.tray-piece { aspect-ratio: 1.05; display: grid; place-items: center; border: 1px solid transparent; background: #172633; padding: 0; min-width: 0; height: auto; cursor: grab; user-select: none; }
.tray-piece:hover { background: #263b4c; }
.tray-piece[aria-pressed="true"] { background: #364451; border-color: var(--accent); }
.tray-piece canvas { display: block; width: 94%; height: auto; pointer-events: none; filter: drop-shadow(0 2px 2px #0009); }
.tray-piece { touch-action: none; }
.tray-piece.dragging { opacity: .25; }
.ghost { position: fixed; z-index: 30; pointer-events: none; filter: drop-shadow(0 5px 5px #0009); }
.empty { grid-column: 1 / -1; margin: 11px; color: var(--muted); }
.instruction { color: var(--muted); font-size: .85rem; line-height: 1.4; padding: 11px 14px; min-height: 42px; }
.footer { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding-block: 10px 18px; font-size: .85rem; color: var(--muted); }
.footer a { color: var(--muted); }
dialog { width: min(660px, calc(100% - 28px)); max-height: min(92dvh, 850px); padding: 0; border: 1px solid #526575; color: var(--text); background: var(--panel); box-shadow: 0 30px 100px #000a; }
dialog::backdrop { background: #090f16d9; }
.dialog-head { display: flex; gap: 12px; padding: 13px 16px; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.dialog-head h2 { font-size: clamp(1.4rem, 4.5vw, 2rem); }
.dialog-body { padding: 15px 16px 19px; display: grid; gap: 13px; }
.dialog-body p, .credit-list { color: var(--muted); font-size: .94rem; line-height: 1.5; }
.dialog-body h3 { font-size: 1.14rem; }
.dialog-body > button { justify-self: start; }
.preview-image { display: block; width: 100%; max-height: 69dvh; object-fit: contain; background: #14202a; }
#win .preview-image { max-height: 48dvh; }
#win-bonus { color: var(--accent-hover); }
.catalog { display: grid; grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)); gap: 5px; }
.catalog button, .catalog-item { min-width: 0; text-align: left; white-space: normal; overflow-wrap: anywhere; }
.catalog-item { font-size: .88rem; border: 1px solid var(--line); padding: 8px 10px; color: var(--muted); }
.profile-controls { display: flex; gap: 8px; margin-top: 6px; }
.profile-controls input { width: 100%; min-width: 0; color: var(--text); background: var(--board); padding: 7px 9px; border: 1px solid var(--line); }
.rank, .credit-list { padding-left: 24px; margin: 0; }
.rank li, .credit-list li { margin-block: 5px; }
.rank li[aria-current="true"] { color: var(--accent-hover); }
@media (min-width: 801px) {
  .tray-panel .tray { position: absolute; inset: 90px 13px 45px; height: auto; margin: 0; }
  .tray-panel .instruction { margin-top: auto; }
}
@media (max-width: 800px) {
  .play-area { grid-template-columns: 1fr; gap: 10px; }
  .tray { max-height: 34dvh; min-height: 102px; padding-right: 20px; grid-template-columns: repeat(var(--mobile-cols, 6), minmax(0, 1fr)); touch-action: pan-y; }
}
@media (max-width: 540px) {
  .masthead-inner { min-height: 57px; }
  .identity, .player-tools { gap: 6px; }
  .mark { width: 25px; height: 25px; font-size: 15px; }
  .head-action { font-size: .8rem; }
  .points { margin-left: 0; min-width: 16px; }
  .game-bar { flex-wrap: wrap; gap: 10px; justify-content: space-between; }
  .round-title { flex-basis: 100%; }
  .round-title h2 { font-size: 1.87rem; }
  .board, .tray { margin-inline: 8px; }
  .panel-head { padding-inline: 9px; min-height: 44px; }
  .controls { margin: 7px 8px; gap: 4px; }
  .controls .button { padding-inline: 7px; min-height: 36px; }
  .tray-filters { padding-left: 8px; }
  .instruction { min-height: 38px; padding: 8px; }
}
.completed-image { display: block; width: 100%; height: 100%; object-fit: fill; }
