/* Structure only. Every colour comes from the theme, so app.css never changes
 * when you swap themes/<name>/. */

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%;
  background: var(--ground); color: var(--ink);
  font-family: var(--ui);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ONE CENTRED COLUMN, ON EVERY SCREEN.
 *
 * The old layout put the stage on the left of a 1180px page with a rail of
 * cards beside it from 900px up. It is gone and it is not coming back by
 * default: what it actually looked like was a phone screenshot pinned to the
 * left of a mostly empty page with two widgets floating next to it. The
 * leaderboard and the countdown were never needed beside the board — they
 * belong on the screens that are about them.
 *
 * The stage is still ONE FIXED PORTRAIT BOX, because that is what makes "what
 * was on screen" identical for every player and a leaderboard comparable. It
 * is simply centred now, with nothing competing with it. */
#app {
  height: 100%;
  display: grid;
  grid-template-rows: auto 1fr;
  grid-template-areas: "top" "stage";
  max-width: 520px; margin: 0 auto;
  padding: 0 max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-bottom));
}

#top {
  grid-area: top;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: max(10px, env(safe-area-inset-top)) 2px 10px;
}
#wordmark {
  font-family: var(--display); font-size: clamp(20px, 5.5vw, 30px);
  letter-spacing: .04em; text-transform: uppercase; margin: 0; font-weight: 400;
}
#wordmark span { color: var(--accent); }
.chip {
  min-width: 42px; min-height: 42px; border-radius: var(--radius);
  border: var(--rule-w) solid var(--rule); background: var(--panel); color: var(--ink);
  font: inherit; font-size: 15px; cursor: pointer;
}
.chip:active { transform: translateY(1px); }

/* THE STAGE IS THE GAME.
 *
 * One portrait box, 10:16, identical on every device — so "what was on screen"
 * is the same rectangle for every player, which is what makes a daily fair and
 * a leaderboard comparable. On a phone it is the screen. On a laptop it is a
 * framed play surface, centred, with nothing beside it.
 *
 * Note it is the stage itself that carries the frame — no panel inside a panel.
 * A screen drops its content straight in. */
#stage {
  grid-area: stage;
  position: relative;                 /* a game's splash layer anchors to this */
  width: 100%; max-width: 420px; margin: 0 auto;
  aspect-ratio: 10 / 16; max-height: 100%;
  display: flex; flex-direction: column;
  container-type: inline-size;
  background: var(--panel);
  border: var(--rule-w) solid var(--rule);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hard);
  padding: 18px;
  overflow: hidden;
}

/* A screen fills the stage and centres itself; a game usually wants the whole
   height instead, so it just does not use this. */
.screen { margin: auto 0; width: 100%; }
/* When a game has drawn its own title backdrop, the words need a ground to be
   read on — a flat plate in the house style, not a gradient over a photograph. */
.screen.on-splash {
  position: relative; z-index: 1;
  margin: auto 0 0;                   /* sit at the foot, so the game's own
                                         backdrop is not hidden behind the words */
  background: color-mix(in srgb, var(--ground) 90%, transparent);
  border: var(--rule-w) solid var(--rule-soft);
  border-radius: var(--radius);
  padding: 20px 14px;
}
/* A TITLE MUST NEVER BREAK MID-WORD. `.big` sets overflow-wrap:anywhere so a
   long RESULT headline can wrap rather than overflow, which is right there and
   wrong here: over a splash the one string is the game's name, and
   "HOUSEKEEPIN / G" is not a title screen, it is a bug. Shrink it, never break
   it. */
.screen.on-splash .big {
  font-size: clamp(20px, 8.2cqw, 38px);
  overflow-wrap: normal; word-break: keep-all; hyphens: none;
}
.btn {
  display: block; width: 100%; min-height: 52px; padding: 14px;
  font: inherit; font-weight: 700; font-size: 17px; cursor: pointer;
  color: var(--accent-ink); background: var(--accent);
  border: var(--rule-w) solid var(--rule); border-radius: var(--radius);
  box-shadow: var(--shadow-hard);
}
.btn:active { transform: translate(2px, 2px); box-shadow: none; }
.btn.ghost { background: var(--panel); color: var(--ink); }
.btn + .btn { margin-top: 10px; }
.label { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--ink-dim); }
/* Headlines are written by the game and can be any length, so this has to wrap
   rather than trust the author. A clipped result is the last thing a player
   sees before they decide whether to share. */
.big {
  font-family: var(--display); font-size: clamp(26px, 11cqw, 52px);
  line-height: .95; letter-spacing: .02em;
  overflow-wrap: anywhere; text-wrap: balance;
}
.strip { font-size: 22px; letter-spacing: 2px; line-height: 1.5; word-break: break-all; }
.row { display: flex; gap: 12px; }
.row > * { flex: 1; }
.center { text-align: center; }
.muted { color: var(--ink-dim); }
.stack > * + * { margin-top: 14px; }

/* Where a game draws what the player just made, above the headline. It gets
   the width and whatever height it asks for; most of the stage is empty on a
   result screen anyway. */
.resultart { display: flex; justify-content: center; }
.resultart canvas { display: block; border-radius: 8px; max-width: 100%; }

/* The foot of the front screen: the things the corner icons used to hide. */
.feet { display: flex; flex-wrap: wrap; justify-content: center; gap: 4px 18px; margin-top: 4px; }
.textlink {
  background: none; border: 0; padding: 6px 2px; font: inherit; font-size: 13px;
  color: var(--ink-dim); text-decoration: underline; text-underline-offset: 3px; cursor: pointer;
}
.textlink:hover { color: var(--ink); }

ol.board { list-style: none; margin: 0; padding: 0; font-variant-numeric: tabular-nums; }
ol.board li { display: flex; gap: 10px; padding: 7px 6px; border-radius: 6px; font-size: 14px; }
ol.board li:nth-child(odd) { background: var(--panel-2); }
ol.board li.me { outline: var(--rule-w) solid var(--accent); }
ol.board .r { width: 26px; text-align: right; color: var(--ink-dim); }
ol.board .n { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
ol.board .v { font-weight: 700; }

.sheet {
  position: fixed; inset: 0; z-index: 40; display: grid; place-items: end center;
  background: rgba(0,0,0,.45); padding: 0;
}
.sheet[hidden] { display: none; }
.sheet-body {
  width: min(460px, 100%); max-height: 88vh; overflow-y: auto;
  background: var(--panel); color: var(--ink);
  border: var(--rule-w) solid var(--rule); border-radius: var(--radius) var(--radius) 0 0;
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
}
@media (min-width: 700px) { .sheet { place-items: center; } .sheet-body { border-radius: var(--radius); } }

#toast {
  position: fixed; left: 50%; bottom: 26px; transform: translate(-50%, 14px);
  background: var(--ink); color: var(--ground); padding: 10px 16px; border-radius: 999px;
  font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 60;
}
#toast.on { opacity: 1; transform: translate(-50%, 0); }
