/* Self-Care Speedrun – the play area is a full-screen pastel canvas (the Unwindr app, drawn in js/game.js). Everything
   on top of it (corner buttons, menus, results, the journey) is the studio frame: square corners, 3px black outlines,
   hard offset shadows, flat colour, Rubik. Short screens (max-height: 430px) put menu buttons in a right-hand column. */
:root {
  --paper: #FAF7F0; --beige: #EFE7D3; --slate: #4C5966; --ink: #1E2328; --k: #000;
  --coral: #FF6B57; --sunny: #FFC845; --sky: #3DA5F4; --glow: #80FF84; --grape: #7A5CFF; --slime: #22AA3A;
  --cream: #FFFAF2;
  --gut: max(10px, env(safe-area-inset-left));
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: var(--cream); color: var(--ink);
  font: 400 16px/1.35 Rubik, system-ui, sans-serif;
  -webkit-tap-highlight-color: transparent; -webkit-user-select: none; user-select: none;
  touch-action: none; overscroll-behavior: none;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

.corner-btns { position: fixed; top: max(8px, env(safe-area-inset-top)); right: max(10px, env(safe-area-inset-right)); display: flex; gap: 8px; z-index: 15; }
.sq-btn {
  width: 38px; height: 36px; padding: 0; cursor: pointer; font-weight: 800;
  background: var(--beige); border: 3px solid var(--k); box-shadow: 3px 3px 0 var(--k);
}
.sq-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--k); }
.sq-btn[aria-pressed="true"] { text-decoration: line-through; background: #CFC6B0; }

/* ---- Frame: menus ---- */
.screen {
  position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center;
  padding: max(58px, calc(env(safe-area-inset-top) + 54px)) var(--gut) max(14px, env(safe-area-inset-bottom));
}
#s-pause, #s-results, #s-journey { background: rgba(75, 69, 96, 0.45); }
.card {
  width: min(100%, 620px); max-height: 100%; overflow: auto;
  display: flex; flex-direction: column; gap: 14px; padding: 18px 20px;
  background: var(--paper); border: 3px solid var(--k); box-shadow: 5px 5px 0 var(--k);
}
.small-card { width: min(100%, 460px); }
h1, h2 { margin: 0; font-weight: 800; line-height: 1.05; }
h1 { font-size: clamp(38px, 8vw, 60px); }
h2 { font-size: 30px; }
p { margin: 0; }
.kicker { font: 700 13px/1.2 Rubik, sans-serif; color: var(--slate); margin-bottom: 4px; }
.dek { font-size: 18px; font-weight: 500; margin-top: 6px; }
.how { margin-top: 8px; }
.keys { margin-top: 8px; font-size: 13px; color: var(--slate); }
body.touch .keys { display: none; }
.fine { font-size: 13px; color: var(--slate); }
.tc-btns { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.btn {
  min-height: 44px; padding: 8px 16px; cursor: pointer;
  background: var(--paper); border: 3px solid var(--k); box-shadow: 4px 4px 0 var(--k);
  font: 700 17px/1.1 Rubik, sans-serif;
}
.btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--k); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--sunny); }
.btn.small { min-height: 36px; font-size: 14px; padding: 6px 12px; }
.btn:focus-visible, .sq-btn:focus-visible, .j-tile:focus-visible, .chip:focus-visible { outline: 3px solid var(--grape); outline-offset: 2px; }
.count { display: inline-block; min-width: 1.4em; padding: 0 6px; background: var(--sunny); border: 3px solid var(--k); font-size: 0.7em; text-align: center; vertical-align: middle; }

/* Results */
.results-card { width: min(100%, 640px); }
.big-score { font: 800 52px/1 Rubik, sans-serif; margin-top: 10px; font-variant-numeric: tabular-nums; }
.big-score small { font-size: 18px; font-weight: 700; color: var(--slate); }
.r-stats { margin-top: 8px; font-weight: 500; }
.r-emoji { margin-top: 8px; font-size: 24px; letter-spacing: 0.06em; line-height: 1.2; }
.r-emoji:empty { display: none; }
#r-fine { margin-top: 8px; }
.status { font-size: 14px; font-weight: 500; width: 100%; }
.status:empty { display: none; }

/* Wellness Journey */
.list-card { width: min(100%, 820px); height: min(100%, 700px); overflow: hidden; }
.c-head .dek { font-size: 15px; }
.j-grid {
  flex: 1; min-height: 0; overflow: auto; margin: 0; padding: 2px 6px 6px 2px; list-style: none;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; align-content: start;
}
.j-grid h3 { grid-column: 1 / -1; margin: 6px 0 0; font-size: 16px; font-weight: 800; }
.j-tile {
  display: flex; flex-direction: column; gap: 4px; width: 100%; padding: 6px; text-align: left; cursor: pointer;
  background: var(--paper); border: 3px solid var(--k); box-shadow: 3px 3px 0 var(--k);
}
.j-tile canvas { display: block; width: 100%; aspect-ratio: 16 / 10; border: 3px solid var(--k); background: var(--beige); }
.j-tile b { font-size: 14px; font-weight: 700; line-height: 1.15; }
.j-tile small { font-size: 12px; color: var(--slate); line-height: 1.2; }
.j-tile.locked { cursor: default; background: #E4DDCC; color: var(--slate); box-shadow: none; }
.j-tile.locked canvas { opacity: 0.25; }
.j-tile[aria-pressed="true"] { background: var(--sunny); }
.c-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.j-pick { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.j-sel { font-weight: 700; font-size: 14px; }
.j-speeds { display: inline-flex; gap: 4px; }
.chip {
  min-width: 34px; height: 32px; padding: 0 6px; cursor: pointer; font: 700 14px/1 Rubik, sans-serif;
  background: var(--paper); border: 3px solid var(--k);
}
.chip[aria-checked="true"] { background: var(--grape); color: var(--paper); }
.j-btns { display: flex; gap: 8px; }

/* ---- Layout by state ---- */
body:not(.st-title) .ml-arcade { display: none !important; }

/* Short screens (phones sideways): text left, buttons in a column on the right. */
@media (max-height: 430px) {
  .screen { padding-top: max(48px, calc(env(safe-area-inset-top) + 44px)); padding-bottom: 8px; }
  .card { flex-direction: row; gap: 14px; padding: 12px 14px; align-items: stretch; }
  .tc-text { flex: 1; min-width: 0; overflow: auto; }
  .tc-btns { flex-direction: column; flex-wrap: nowrap; align-items: stretch; flex: none; width: 180px; gap: 7px; overflow: auto; padding: 0 5px 5px 0; }
  .btn { min-height: 34px; padding: 5px 10px; font-size: 15px; }
  .btn.small { min-height: 30px; }
  h1 { font-size: 32px; } h2 { font-size: 22px; }
  .title-card .kicker { display: none; }
  .dek { font-size: 15px; } .how { font-size: 14px; margin-top: 4px; }
  .big-score { font-size: 34px; margin-top: 4px; } .r-emoji { font-size: 18px; margin-top: 4px; }
  .r-stats { font-size: 14px; margin-top: 4px; }
  .list-card {
    display: grid; grid-template-columns: 1fr 200px; grid-template-rows: auto 1fr; height: 100%;
    grid-template-areas: "grid head" "grid foot"; gap: 8px 12px;
  }
  .list-card .c-head { grid-area: head; } .list-card .j-grid { grid-area: grid; } .list-card .c-foot { grid-area: foot; }
  .list-card .c-head .dek { display: none; }
  .list-card .c-foot { flex-direction: column; align-items: stretch; justify-content: flex-end; }
  .j-btns { flex-direction: column; } .j-btns .btn { width: 100%; }
  .j-grid { grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 6px; }
  .j-tile small { display: none; }
  .chip { min-width: 30px; height: 28px; }
}
@media (max-width: 520px) {
  .j-grid { grid-template-columns: 1fr 1fr; }
}
