/* Open Secret · Go Daily look: bold ink outlines, pop shadows, Baloo 2 headings. Colours come from themes.css. */
* { box-sizing: border-box; }
/* Safe areas (notch, rounded corners, home indicator) as variables so tests can simulate them. */
:root { --safe-t: env(safe-area-inset-top, 0px); --safe-r: env(safe-area-inset-right, 0px); --safe-b: env(safe-area-inset-bottom, 0px); --safe-l: env(safe-area-inset-left, 0px);
  --good: #0C8365; --near: #E8A317; --miss: #8A8698; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--background); color: var(--foreground);
  font: 500 16px/1.4 Nunito, system-ui, -apple-system, sans-serif;
  -webkit-tap-highlight-color: transparent; overscroll-behavior: none;
}
h1, h2, h3, .display { font-family: "Baloo 2", Nunito, system-ui, sans-serif; line-height: 1.1; margin: 0; }
button, input, select { font: inherit; color: inherit; }
#app { min-height: 100dvh; display: flex; flex-direction: column; }
.brand { color: var(--primary); }
html[data-mode="dark"] .brand { color: var(--foreground); }
@media (prefers-color-scheme: dark) { html:not([data-mode="light"]) .brand { color: var(--foreground); } }

.page { max-width: 520px; width: 100%; margin: 0 auto; padding: calc(16px + var(--safe-t)) max(16px, var(--safe-r)) calc(24px + var(--safe-b)) max(16px, var(--safe-l)); display: flex; flex-direction: column; gap: 16px; }
.card { background: var(--card); border: 2px solid var(--foreground); border-radius: 18px; padding: 18px; box-shadow: 0 4px 0 var(--shadow); }
.muted { color: var(--muted-foreground); }
.small-note { font-size: 13px; margin: 0; }
.row { display: flex; gap: 10px; align-items: center; }
.grow { flex: 1; }
.center { text-align: center; }
.stack { display: flex; flex-direction: column; gap: 10px; }

.btn {
  appearance: none; border: 2px solid var(--foreground); border-radius: 14px; padding: 12px 18px; min-height: 48px;
  background: var(--card); color: var(--foreground); font-weight: 800; box-shadow: 0 3px 0 var(--foreground); cursor: pointer; touch-action: manipulation;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 var(--foreground); }
.btn.primary { background: var(--primary); color: var(--primary-foreground); }
.btn.sun { background: var(--sun); color: var(--sun-foreground); }
.btn.big { font-family: "Baloo 2", sans-serif; font-size: 24px; padding: 8px 22px; min-height: 58px; }
.btn:disabled { opacity: 0.45; box-shadow: none; transform: none; cursor: default; }
.btn.small { min-height: 38px; padding: 6px 12px; font-size: 14px; box-shadow: 0 2px 0 var(--foreground); }
.link { background: none; border: 0; color: var(--primary); font-weight: 800; padding: 8px; cursor: pointer; }
html[data-mode="dark"] .link { color: var(--accent); }
@media (prefers-color-scheme: dark) { html:not([data-mode="light"]) .link { color: var(--accent); } }
input.field { width: 100%; border: 2px solid var(--foreground); border-radius: 14px; padding: 12px 14px; min-height: 50px; background: var(--background); font-size: 18px; font-weight: 700; }
input.code { text-transform: uppercase; letter-spacing: 0.3em; text-align: center; font-family: "Baloo 2", sans-serif; font-size: 24px; }
label.lbl, .lbl { font-weight: 800; font-size: 14px; }
.error { color: var(--destructive); font-weight: 700; min-height: 1.4em; }

/* Home */
.hero { text-align: center; padding-top: 8px; }
.hero h1 { font-size: 44px; color: var(--primary); }
html[data-mode="dark"] .hero h1 { color: var(--foreground); }
@media (prefers-color-scheme: dark) { html:not([data-mode="light"]) .hero h1 { color: var(--foreground); } }
.hero-tiles { justify-content: center; margin: 10px 0 6px; }
.howto ol { margin: 8px 0 0; padding-left: 20px; }
.howto li { margin: 6px 0; }
.foot { display: flex; gap: 10px; align-items: center; justify-content: center; font-size: 14px; }
.foot select { border: 2px solid var(--border); border-radius: 10px; background: var(--card); padding: 6px; }

/* Lobby */
.code-big { font-family: "Baloo 2", sans-serif; font-size: 46px; letter-spacing: 0.18em; text-align: center; margin: 4px 0; }
.players { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.players li { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 2px solid var(--border); border-radius: 12px; background: var(--background); font-weight: 800; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: var(--leaf); flex: none; }
.dot.away { background: var(--muted-foreground); opacity: 0.5; }
.badge { font-size: 12px; font-weight: 800; padding: 2px 8px; border-radius: 99px; background: var(--secondary); color: var(--foreground); }
.seg { display: flex; gap: 6px; }
.seg button { flex: 1; }
.seg button[aria-pressed="true"] { background: var(--primary); color: var(--primary-foreground); }

/* Letter tiles */
.wordrow { display: flex; gap: 4px; }
.t {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 7px;
  border: 2px solid var(--foreground); background: var(--card); color: var(--foreground);
  font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 20px; line-height: 1; padding-top: 2px;
}
.t.big { width: 54px; height: 54px; font-size: 32px; border-radius: 10px; box-shadow: 0 3px 0 var(--foreground); }
.t.mid { width: 42px; height: 42px; font-size: 26px; border-radius: 9px; }
.t.sm { width: 28px; height: 28px; font-size: 17px; border-radius: 6px; border-width: 2px; }
.t.xs { width: 22px; height: 22px; font-size: 13px; border-radius: 5px; border-width: 1.5px; }
.t.ghost { border-style: dashed; border-color: var(--border); background: transparent; }
.t.mG { background: var(--good); border-color: var(--good); color: #fff; }
.t.mY { background: var(--near); border-color: var(--near); color: #2A1457; }
.t.mB { background: var(--miss); border-color: var(--miss); color: #fff; }
.t.mine { background: var(--sun); color: var(--sun-foreground); }
.peek { cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.t.hid { color: var(--muted-foreground); letter-spacing: 0; }
.t.mine.hid { color: var(--sun-foreground); }
.holdhint { font-size: 10px; font-weight: 800; color: var(--muted-foreground); text-align: center; line-height: 1; }
.dots { display: flex; gap: 4px; height: 10px; }
.dots span { width: 28px; text-align: center; font-size: 12px; line-height: 8px; color: var(--accent); letter-spacing: -1px; overflow: hidden; }

/* Choosing */
.choose .wordrow { justify-content: center; }

/* Playing */
.play { height: 100dvh; display: flex; flex-direction: column; max-width: 720px; width: 100%; margin: 0 auto; padding: 0 var(--safe-r) 0 var(--safe-l); }
.ptop { display: flex; align-items: center; gap: 8px; padding: calc(6px + var(--safe-t)) 12px 4px; }
.ptop h2 { font-size: 21px; }
.round { font-weight: 800; font-size: 13px; color: var(--muted-foreground); }
.clock { font-family: "Baloo 2", sans-serif; font-weight: 800; font-size: 18px; min-width: 44px; text-align: center; padding: 0 8px; border: 2px solid var(--foreground); border-radius: 99px; background: var(--sun); color: var(--sun-foreground); }
.clock:empty { display: none; }
.clock.low { background: var(--destructive); color: #fff; }
.mine { padding: 0 12px 6px; }
.minecard { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 14px; background: var(--secondary); }
.minecard .wordcol { display: flex; flex-direction: column; gap: 2px; }
.minecard .dots span { width: 28px; }
.mlabel { font-size: 12px; font-weight: 800; color: var(--muted-foreground); }
.mlabel.right { margin-left: auto; text-align: right; max-width: 34%; }
.boards { flex: 1; min-height: 0; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 8px; padding: 4px 12px 8px; align-content: start; }
.bcard { border: 2px solid var(--border); border-radius: 14px; background: var(--card); padding: 7px 8px; display: flex; flex-direction: column; gap: 4px; cursor: pointer; }
.bcard.focus { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary); }
.bcard.won { background: color-mix(in oklab, var(--good) 14%, var(--card)); }
.bhead { display: flex; align-items: center; gap: 6px; font-size: 14px; }
.bhead b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cracks { font-size: 12px; font-weight: 800; }
.hist { display: flex; gap: 3px; }
.hist .t.xs { width: 22px; }
.hist.code { justify-content: space-between; font-weight: 800; font-size: 13px; }
.hist .hg { letter-spacing: 0.12em; }
.hist .cnt { color: var(--good); letter-spacing: 1px; }
.bnote { font-size: 13px; font-weight: 800; color: var(--good); }
.more { font-size: 11px; font-weight: 800; color: var(--muted-foreground); }
.entry { padding: 4px 6px calc(6px + var(--safe-b)); border-top: 2px solid var(--border); background: var(--background); }
.entryrow { display: flex; align-items: center; gap: 10px; padding: 4px 6px 6px; }
.entrytile { box-shadow: 0 2px 0 var(--foreground); }
.sent { font-size: 13px; font-weight: 800; line-height: 1.25; flex: 1; text-align: right; }
.kb { display: flex; flex-direction: column; gap: 6px; }
.kbrow { display: flex; gap: 5px; justify-content: center; }
.key { flex: 1; max-width: 42px; height: 48px; border: 0; border-radius: 8px; background: var(--muted); color: var(--foreground); font-weight: 800; font-size: 16px; touch-action: manipulation; cursor: pointer; padding: 0; }
.key.wide { max-width: 64px; flex: 1.5; font-size: 13px; }
.key:active { filter: brightness(0.85); }
.key.mG { background: var(--good); color: #fff; }
.key.mY { background: var(--near); color: #2A1457; }
.key.mB { background: var(--miss); color: #fff; opacity: 0.75; }

/* Final */
.winner { text-align: center; }
.winner .emoji { font-size: 54px; }
.scores { width: 100%; border-collapse: collapse; }
.scores td { padding: 8px 4px; border-bottom: 1px solid var(--border); font-weight: 800; vertical-align: middle; }
.scores td:last-child { text-align: right; font-family: "Baloo 2", sans-serif; font-size: 22px; }
.wordcell .wordrow { gap: 2px; }

/* Toast + modal */
#toast { position: fixed; left: 50%; top: calc(12px + var(--safe-t)); transform: translate(-50%, -150%); z-index: 60;
  background: var(--foreground); color: var(--background); padding: 10px 16px; border-radius: 14px; font-weight: 800; max-width: 92vw; text-align: center;
  visibility: hidden; opacity: 0; transition: transform 0.25s, opacity 0.25s, visibility 0s 0.25s; }
#toast.show { transform: translate(-50%, 0); visibility: visible; opacity: 1; transition: transform 0.25s, opacity 0.25s; }
#modal { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: rgba(20, 8, 40, 0.5); padding: 16px; }
#modal[hidden] { display: none; }
#modal .card { max-width: 380px; width: 100%; }

/* Small phones: tighter keyboard */
@media (max-height: 700px) { .key { height: 42px; } .t.mid { width: 36px; height: 36px; font-size: 22px; } }

/* Landscape phones: boards on the left, your word + entry + keyboard on the right. */
@media (orientation: landscape) and (max-height: 560px) {
  .play { display: grid; max-width: none; grid-template-columns: minmax(0, 1fr) clamp(300px, 44vw, 420px);
    grid-template-rows: auto auto 1fr; grid-template-areas: "top top" "boards mine" "boards entry"; height: 100dvh; }
  .ptop { grid-area: top; padding-top: calc(4px + var(--safe-t)); }
  .boards { grid-area: boards; padding-bottom: calc(6px + var(--safe-b)); }
  .mine { grid-area: mine; }
  .entry { grid-area: entry; border-top: 0; align-self: end; }
  .key { height: 38px; }
  .kb { gap: 4px; }
}
