:root { color-scheme: dark; }
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: #0b0908;
  display: flex; align-items: center; justify-content: center;
  padding: max(0px, env(safe-area-inset-top, 0px)) 0 max(0px, env(safe-area-inset-bottom, 0px));
}
/* The game is the whole interface. Everything else is pixels inside it. */
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
#screen {
  width: 100%; max-width: min(100vw, calc(100vh * 2.2));
  aspect-ratio: 880 / 400;
  image-rendering: pixelated;
  background: #0b0908; touch-action: none; display: block;
}
/* Fit the game to the visible area. The fullscreen icon overlays its corner. */
html:not(.dev) body {
  width: var(--view-w, 100vw); height: var(--view-h, 100dvh);
  overflow: hidden;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
}
html:not(.dev) #screen {
  --available-h: calc(var(--view-h, 100dvh) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  width: min(100%, calc(var(--available-h) * 2.2));
  height: auto; max-width: 100%; min-width: 0; flex: none;
}
#display-tools {
  position: fixed; width: 40px; height: 40px; z-index: 2;
}
#fullscreen-toggle {
  flex: none; width: 100%; height: 100%; padding: 4px; border: 2px solid #b1854a;
  background: #33241a; color: #f2b33d; cursor: pointer;
  box-shadow: inset -2px -2px #140f0d, inset 2px 2px #66492e;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
#fullscreen-toggle canvas { width: 100%; height: 100%; image-rendering: pixelated; display: block; }
#fullscreen-toggle:hover, #fullscreen-toggle:focus-visible { border-color: #f2b33d; outline: 2px solid #f2b33d; outline-offset: -2px; }
#fullscreen-toggle:active { background: #4a3323; }
#display-status { position: absolute; right: 6px; bottom: 46px; width: min(320px, calc(100vw - 12px)); color: #f6dc9a; font: 12px/1.5 monospace; background: #221812; border: 1px solid #b1854a; padding: 8px; }
#display-status:empty { display: none; }

#rotate { display: none; }
@media (orientation: portrait) and (max-width: 900px) {
  #screen { display: none; }
  #rotate {
    display: flex; flex-direction: column; align-items: center; gap: 18px;
    text-align: center; padding: 24px; color: #8a6338;
    font-family: ui-sans-serif, system-ui, sans-serif;
  }
  #rotate .phone {
    width: 84px; height: 140px; border: 4px solid #f2b33d; border-radius: 10px;
    animation: tip 2.2s ease-in-out infinite;
  }
  #rotate b { color: #f2b33d; font-size: 18px; letter-spacing: 2px; }
  #rotate span { font-size: 13px; }
}
@keyframes tip { 0%,45% { transform: rotate(0deg); } 65%,100% { transform: rotate(-90deg); } }
@media (prefers-reduced-motion: reduce) { #rotate .phone { animation: none; transform: rotate(-90deg); } }

/* The board: the one piece of the game that is HTML, because three initials
   want a real text field. It sits over the canvas in the game's own colours. */
.dp-board { position: fixed; inset: 0; display: flex; align-items: center; justify-content: center; background: #0b0908d9; z-index: 10; padding: 16px; }
.dp-board[hidden] { display: none; }
.dp-board-card {
  width: min(520px, 94%); max-height: 94%; overflow: auto; padding: clamp(16px, 3vw, 30px); text-align: center;
  color: #ffe9c2; font: 800 14px/1.4 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .08em;
  border: 2px solid #f2b33d; background: #1a120c; box-shadow: 0 16px 60px #000c, inset 0 0 0 4px #0b0908;
}
.dp-board-card .dp-eyebrow { margin: 0; color: #b1854a; font-size: 12px; letter-spacing: .3em; }
.dp-board-card h2 { margin: 6px 0 8px; color: #f2b33d; font-size: clamp(24px, 4.5vw, 40px); letter-spacing: .06em; }
.dp-board-card .dp-copy, .dp-board-card .dp-message { margin: 6px 0 10px; color: #d8ab63; font-size: 12px; min-height: 1.2em; }
.dp-form { display: grid; justify-items: center; gap: 12px; margin: 10px 0 14px; }
.dp-form[hidden] { display: none; }
.dp-form label { display: grid; gap: 8px; color: #ffe9c2; font-size: 12px; letter-spacing: .2em; }
.dp-form input {
  width: 5ch; padding: 6px 8px; text-align: center; text-transform: uppercase;
  font: 800 30px/1 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .3em; color: #fffbe8;
  background: #0b0908; border: 2px solid #b1854a; border-radius: 4px; outline: none;
}
.dp-form input:focus { border-color: #f2b33d; box-shadow: 0 0 14px #f2b33d55; }
.dp-primary {
  padding: 10px 18px; font: 800 14px/1 ui-monospace, Menlo, Consolas, monospace; letter-spacing: .14em; cursor: pointer;
  color: #0b0908; background: #f2b33d; border: 2px solid #ffe9c2; border-radius: 4px;
}
.dp-primary:hover, .dp-primary:focus-visible { background: #ffe9c2; }
.dp-primary[hidden] { display: none; }
.dp-list { list-style: none; counter-reset: rank; margin: 8px 0 10px; padding: 0; display: grid; gap: 6px; text-align: left; }
.dp-list[hidden] { display: none; }
.dp-list li { display: grid; grid-template-columns: 2.2em 5em 1fr auto; align-items: baseline; gap: 10px; padding: 6px 10px; background: #0b0908; border: 1px solid #4a3323; }
.dp-list li::before { counter-increment: rank; content: counter(rank) "."; color: #b1854a; text-align: right; }
.dp-list .dp-initials { color: #ffe9c2; font-size: 18px; letter-spacing: .2em; }
.dp-list .dp-score { color: #f2b33d; font-size: 18px; text-align: right; }
.dp-list .dp-detail { color: #8a6338; font-size: 11px; }
.dp-list .dp-empty { display: block; text-align: center; color: #8a6338; }

/* Dev notes: the parent's companion box, HTML beside the canvas, only with
   ?dev=1. Modern and plain on purpose — it is not part of the game. */
html.dev body { gap: 18px; padding-left: 12px; padding-right: 12px; overflow: auto; }
/* beside the box the canvas gives up the phone's fill-the-screen rule, whatever the window's height */
html.dev #screen { height: auto; width: 100%; min-width: 0; object-fit: fill; max-width: min(calc(100vw - 400px), calc(100vh * 2.2)); }
.dev-notes {
  color-scheme: light; width: 350px; max-height: calc(100vh - 24px); overflow: auto; flex: none;
  background: #f3f3f3; color: #1b1b1b; border: 1px solid #e0e0e0; border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0,0,0,.45); padding: 14px 16px 12px;
  font: 14px/1.4 "Segoe UI", ui-sans-serif, system-ui, sans-serif; display: flex; flex-direction: column; gap: 10px;
}
.dev-notes header { display: flex; align-items: center; justify-content: space-between; position: sticky; top: -14px; margin: -14px -16px 0; padding: 14px 16px 8px; background: #f3f3f3; z-index: 1; }   /* the buttons stay put while the panel scrolls */
.dev-notes h2 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: .2px; }
.dev-notes button { font: inherit; border-radius: 6px; padding: 6px 12px; cursor: pointer; border: 1px solid #c9c9c9; background: #fbfbfb; color: #1b1b1b; }
.dev-notes button:hover { background: #f0f0f0; }
.dev-notes .dev-save { background: #0067c0; border-color: #0067c0; color: #fff; font-weight: 600; }
.dev-notes .dev-save:hover { background: #1975d1; }
.dev-now { background: #fff; border: 1px solid #e5e5e5; border-radius: 8px; padding: 10px 12px; }
.dev-scene { font-size: 11px; font-weight: 600; letter-spacing: 1px; text-transform: uppercase; color: #6b6b6b; }
.dev-what { margin-top: 4px; font-size: 15px; font-weight: 600; }
.dev-where { margin-top: 4px; font-size: 12px; color: #6b6b6b; }
.dev-box { width: 100%; resize: vertical; min-height: 120px; font: inherit; padding: 10px 12px; border: 1px solid #c9c9c9; border-radius: 8px; background: #fff; color: #1b1b1b; }
.dev-box:focus { outline: 2px solid #0067c0; outline-offset: 0; border-color: #0067c0; }
.dev-notes footer { display: flex; align-items: center; gap: 10px; }
.dev-status { font-size: 12px; color: #4a4a4a; }
.dev-status.bad { color: #b3261e; }
.dev-hint { margin: 0; font-size: 12px; color: #6b6b6b; }
.dev-notes h3 { margin: 0 0 6px; font-size: 12px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase; color: #6b6b6b; }
.dev-before { background: #fff8e6; border: 1px solid #f0dfb0; border-radius: 8px; padding: 6px 10px; }
.dev-before summary { cursor: pointer; font-size: 12px; font-weight: 600; letter-spacing: .6px; text-transform: uppercase; color: #6b6b6b; user-select: none; }
.dev-before[open] summary { margin-bottom: 4px; }
.dev-feed { border-top: 1px solid #e0e0e0; padding-top: 10px; max-height: 46vh; overflow: auto; }
.dev-note { background: #fff; border: 1px solid #e5e5e5; border-left: 4px solid #c9c9c9; border-radius: 8px; padding: 8px 10px; margin: 6px 0; }
.dev-note.done { border-left-color: #1a7f37; }
.dev-note-where { font-size: 11px; color: #6b6b6b; margin-bottom: 2px; }
.dev-note-when { font-size: 11px; color: #9a9a9a; }
.dev-note-text { margin: 2px 0 4px; white-space: pre-wrap; }
.dev-note-done { font-size: 12px; color: #1a7f37; }
.dev-note:not(.done) .dev-note-done { color: #9a9a9a; font-style: italic; }
.dev-feed-btn { margin-left: auto; margin-right: 8px; }

/* Entry notice overlays the title's empty lower edge, never adds a game row. */
#stats-notice { position: fixed; bottom: max(4px, env(safe-area-inset-bottom, 0px)); left: 48px; width: calc(100% - 96px); margin: 0; padding: 4px; color: #d8ab63; background: #0b0908; z-index: 1; font-size: 11px; }
#stats-notice[hidden] { display: none; }
