:root {
  --bg: #C4CFA1;       /* screen background, panels, jar interior */
  --dim: #8B956D;      /* tick marks, disabled buttons, dim text on ink */
  --page: #4D533C;     /* page behind the screen, button borders */
  --ink: #1F1F1F;      /* jar walls, digits, all text on light panels, hover fill */
  --water: #3A8FC8;
  --surface: #8CC8E8;
  --accent: #E0A030;   /* target flash, selection, focus */
  --good: #5A9E3A;     /* AT PAR marks (never used for text) */
  --bad: #B83A3A;      /* failed marks (never used for text) */
  --mono: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  background: var(--page);
  color: var(--ink);
  font-family: var(--mono);
  font-size: 16px;
  line-height: 1.4;
  text-transform: uppercase;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

#app {
  max-width: 560px;
  min-height: 100%;
  height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
  border-left: 2px solid var(--ink);
  border-right: 2px solid var(--ink);
}

.screen {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  overflow-y: auto;
}
.screen[hidden] { display: none; }
[hidden] { display: none !important; }

h1, h2 { margin: 0; letter-spacing: 0.12em; }
.wordmark { font-size: 40px; letter-spacing: 0.4em; text-align: center; margin-top: 24px; padding-left: 0.4em; }
h2 { font-size: 22px; }
p { margin: 0; }
.sub { text-align: center; }
.noscript { padding: 16px; background: var(--bg); }

.menu { display: flex; flex-direction: column; gap: 10px; }
.hubslot { display: flex; justify-content: center; margin-top: 10px; }
.hublink { display: inline-flex; align-items: center; min-height: 44px; padding: 6px 10px; color: var(--ink); font-weight: 700; text-transform: uppercase; text-decoration: underline; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.row, .row2 { display: grid; gap: 8px; }
.row { grid-template-columns: 1fr 1fr 56px 56px; }
.row2 { grid-template-columns: 1fr 1fr; }

button {
  font: inherit;
  font-weight: 700;
  text-transform: uppercase;
  min-height: 44px;
  padding: 6px 10px;
  color: var(--ink);
  background: var(--bg);
  border: 2px solid var(--page);
  border-radius: 0;
  cursor: pointer;
}
button:hover:not(:disabled) { background: var(--ink); color: var(--bg); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { background: var(--dim); color: var(--ink); cursor: default; }
button[aria-pressed="true"] { border-color: var(--ink); }

/* Focus: the accent outline from the brief, backed by a dark ring so it also reads on the light panel. */
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px var(--ink);
}

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* game: one thumb, top to bottom: top bar, TARGET, flexible space, jars, per-jar controls, RESET and SKIP */
#s-game { padding: 8px 12px 12px; gap: 6px; overflow: hidden; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex: 0 0 auto; }
.topstats { display: flex; flex-direction: column; font-weight: 700; line-height: 1.25; }
.icons { display: flex; gap: 4px; }
.icon { width: 44px; height: 44px; min-width: 44px; padding: 0; display: flex; align-items: center; justify-content: center; }
.icon svg { width: 26px; height: 26px; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon:hover:not(:disabled) svg { stroke: var(--bg); }
.icon .slash { display: none; stroke-width: 2.5; }
.icon[aria-pressed="false"] .slash { display: block; }
.target { flex: 0 0 auto; margin: 0; text-align: center; font-size: clamp(32px, 9vw, 44px); line-height: 1.1; letter-spacing: 0.06em; }
.flex { flex: 1 1 0; min-height: 0; display: flex; align-items: center; justify-content: center; }
#canvas-box { flex: 0 0 auto; display: flex; align-items: center; justify-content: center; }
#canvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: var(--bg);
  border: 0;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
/* The columns are exactly as wide as the canvas (main.js sets --cw), in three equal thirds, so each
   column is centred under its jar to within a canvas pixel. */
.jarcols { flex: 0 0 auto; width: var(--cw, 100%); margin: 0 auto; display: grid; grid-template-columns: repeat(3, 1fr); }
.jarcol { display: flex; flex-direction: column; gap: 6px; padding: 0 4px; min-width: 0; }
.jarletter { text-align: center; font-size: 24px; font-weight: 700; line-height: 1.1; }
.jarcol button { width: 100%; min-height: 44px; }
.bottomrow { flex: 0 0 auto; }
.message { min-height: 1.4em; text-align: center; font-weight: 700; margin: 0; }

/* result */
.rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.rows li { display: grid; grid-template-columns: 1.6em 1fr 4.5em; gap: 8px; align-items: center; white-space: pre; }
.rows .mark { display: inline-block; width: 12px; height: 12px; margin-right: 8px; border: 2px solid var(--ink); vertical-align: -1px; }
.rows .par .mark { background: var(--good); }
.rows .near .mark { background: var(--accent); }
.rows .far .mark { background: var(--dim); }
.rows .fail .mark { background: var(--bad); }
.rows .score { text-align: right; font-weight: 700; }
.total { font-size: 22px; font-weight: 700; text-align: center; }
.reveal { border: 2px solid var(--ink); padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.reveal .head { font-weight: 700; letter-spacing: 0.1em; }
.stats { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.stats li { display: flex; justify-content: space-between; gap: 10px; border-bottom: 1px solid var(--dim); padding: 3px 0; }
.stats b { font-weight: 700; }
.stats .sep { margin-top: 10px; border-bottom: 2px solid var(--ink); font-weight: 700; justify-content: flex-start; }

.keys { border-collapse: collapse; width: 100%; font-size: 14px; }
.keys caption { text-align: left; font-weight: 700; padding: 4px 0; }
.keys th { text-align: left; vertical-align: top; padding: 3px 8px 3px 0; white-space: nowrap; }
.keys td { padding: 3px 0; }
.keys tr { border-top: 1px solid var(--dim); }

.archive { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.archive button { width: 100%; display: flex; justify-content: space-between; text-align: left; gap: 10px; }

textarea {
  width: 100%;
  font: inherit;
  font-size: 14px;
  text-transform: none;
  color: var(--ink);
  background: var(--bg);
  border: 2px solid var(--ink);
  border-radius: 0;
  padding: 6px;
  resize: vertical;
}
label { display: block; font-weight: 700; margin-bottom: 4px; }
.msg { min-height: 1.4em; font-weight: 700; }

.notice {
  display: flex; align-items: center; gap: 10px; justify-content: space-between;
  padding: 8px 14px;
  background: var(--ink);
  color: var(--bg);
}
.notice button { min-width: 44px; color: var(--bg); background: var(--ink); border-color: var(--bg); }
.notice button:hover:not(:disabled) { background: var(--bg); color: var(--ink); }

.dialog-wrap {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(31, 31, 31, 0.7);
  padding: 20px;
  z-index: 10;
}
.dialog {
  background: var(--bg);
  border: 2px solid var(--ink);
  padding: 16px;
  display: flex; flex-direction: column; gap: 14px;
  max-width: 340px; width: 100%;
  font-weight: 700;
}

@media (prefers-reduced-motion: reduce) {
  button:active:not(:disabled) { transform: none; }
}

@media (max-width: 380px) {
  .wordmark { font-size: 32px; }
  .row { grid-template-columns: 1fr 1fr 48px 48px; }
}
