/* style.css: the in-game HTML only (canvas page, on-screen buttons, typing box, pause and game-over cards, rotate hint, toast).
   The menu and splash are styled by ui/menu.css (every class there starts with "rr-"): nothing here touches those names.
   The game sets --accent on :root to the theme's first colour. */
:root {
  --accent: #38f3ff; --fg: #f2f6ff; --dim: rgba(242, 246, 255, .62); --panel: rgba(8, 10, 24, .94); --line: rgba(255, 255, 255, .14);
  --hb: 44px; --hedge: 8px; --hgap: 4px;            /* on-screen button size, edge gap, gap between neighbours (render.js reserves the same room) */
  --st: env(safe-area-inset-top, 0px); --sr: env(safe-area-inset-right, 0px); --sb: env(safe-area-inset-bottom, 0px); --sl: env(safe-area-inset-left, 0px);
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; background: #04050c; color: var(--fg); overflow: hidden; overscroll-behavior: none;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%; touch-action: manipulation;
}
body { position: fixed; inset: 0; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
#c { display: block; position: fixed; inset: 0; width: 100%; height: 100%; }
.hidden { display: none !important; }

/* ---------------------------------------------------------------- on-screen buttons (phones have no Esc, M or B) */
#hudButtons { position: fixed; inset: 0; z-index: 6; pointer-events: none; }
.hudbtn {
  position: absolute; top: calc(var(--hedge) + var(--st)); width: var(--hb); height: var(--hb); margin: 0; padding: 0;
  display: grid; place-items: center; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .22);
  background: rgba(8, 10, 24, .5); color: var(--fg); opacity: .78; cursor: pointer; pointer-events: auto; touch-action: manipulation;
  font: 700 18px/1 system-ui, sans-serif; transition: opacity .15s, background-color .15s, transform .1s;
}
.hudbtn svg { width: 20px; height: 20px; display: block; fill: currentColor; pointer-events: none; }
.hudbtn:hover { opacity: 1; background: rgba(8, 10, 24, .75); }
.hudbtn:active { transform: scale(.92); opacity: 1; }
.hudbtn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; opacity: 1; }
#btnPause { left: calc(var(--hedge) + var(--sl)); }
#btnMute { right: calc(var(--hedge) + var(--hb) + var(--hgap) + var(--sr)); }
#btnFlag { right: calc(var(--hedge) + var(--sr)); }
#btnMute.off, #btnMute[aria-pressed="true"] { opacity: .5; }
#btnMute.off::after, #btnMute[aria-pressed="true"]::after {   /* a slash through the note when the music is off */
  content: ""; position: absolute; left: 50%; top: 50%; width: 26px; height: 2px; margin: -1px 0 0 -13px;
  background: var(--fg); border-radius: 1px; transform: rotate(-45deg); box-shadow: 0 0 0 1px rgba(8, 10, 24, .7);
}

/* ---------------------------------------------------------------- typing fallback box (bottom centre, under the mic status line) */
#type {
  position: fixed; left: 50%; bottom: calc(6px + var(--sb)); transform: translateX(-50%); z-index: 5;
  width: min(360px, calc(100% - 32px)); height: 34px; margin: 0; padding: 0 14px;
  font: 16px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;       /* 16px or more: iOS does not zoom the page on focus */
  color: var(--fg); background: rgba(8, 10, 24, .6); border: 1px solid rgba(255, 255, 255, .18); border-radius: 17px; outline: none;
  user-select: text; -webkit-user-select: text; -webkit-appearance: none; appearance: none;
}
#type::placeholder { color: rgba(242, 246, 255, .42); font-size: 14px; text-overflow: ellipsis; }   /* smaller than the typed text so the hint fits a narrow phone */
@media (max-width: 400px) { #type::placeholder { font-size: 13px; } #type { padding: 0 12px; } }
#type:focus { border-color: var(--accent); background: rgba(8, 10, 24, .85); }

/* ---------------------------------------------------------------- overlays: pause and game over */
.overlay {
  position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center;
  padding: calc(12px + var(--st)) calc(12px + var(--sr)) calc(12px + var(--sb)) calc(12px + var(--sl));
  background: rgba(2, 3, 10, .55);                    /* no backdrop blur: it would be re-blurred on every canvas frame */
}
#over { background: rgba(2, 3, 10, .38); }           /* lighter, so the confetti and fireworks behind the card still show */
.overlay .card {
  width: min(560px, 100%); max-height: 100%; overflow: auto; padding: 24px 28px; text-align: center;
  background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--accent); border-radius: 20px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, .6), 0 0 44px -14px var(--accent); animation: gg-pop .28s cubic-bezier(.2, 1.3, .4, 1) both;
}
.overlay h2 { margin: 0 0 6px; font-size: clamp(26px, 5.5vw, 36px); line-height: 1.1; letter-spacing: .02em; font-weight: 800; }
.overlay .sub { margin: 4px 0 16px; color: var(--dim); font-size: 15px; line-height: 1.4; }
.overlay .stats { margin: 8px 0 0; color: var(--dim); font-size: 16px; line-height: 1.75; }
.overlay .stats b { color: var(--fg); }
.overlay .btns { display: flex; gap: 10px; margin-top: 18px; }
.overlay .btns .go { flex: 1 1 auto; }
.overlay .go, .overlay .btn {
  min-height: 52px; margin: 0; padding: 0 22px; border-radius: 14px; font: inherit; cursor: pointer; touch-action: manipulation;
  -webkit-appearance: none; appearance: none; transition: transform .1s, filter .15s, background-color .15s;
}
.overlay .go { border: 0; background: var(--accent); color: #04050c; font-size: 20px; font-weight: 800; letter-spacing: .08em; box-shadow: 0 8px 24px -10px var(--accent); }
.overlay .btn { color: var(--fg); background: rgba(255, 255, 255, .07); border: 1px solid rgba(255, 255, 255, .2); font-size: 16px; font-weight: 600; }
.overlay .go:hover { filter: brightness(1.1); }
.overlay .btn:hover { background: rgba(255, 255, 255, .13); }
.overlay .go:active, .overlay .btn:active { transform: scale(.97); }
.overlay .go:focus-visible, .overlay .btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.overlay .row { margin: 14px 0 0; }
.overlay .logrow { display: flex; align-items: center; justify-content: center; gap: 12px; }
.overlay .logrow .btn { min-height: 40px; padding: 0 14px; font-size: 14px; flex: none; }
.overlay .info { flex: 0 1 auto; min-height: 18px; color: var(--dim); font-size: 13px; text-align: left; }
.face-canvas { display: block; width: 100%; height: 150px; margin: 0 auto 8px; }
/* the line the face says on the game-over card (the face there has no bubble): plain readable text, at most three lines */
.overline {
  margin: 2px 0 10px; color: var(--fg); font: 600 18px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow-wrap: break-word; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; line-clamp: 3; overflow: hidden;
}
.overline:empty { display: none; }
@keyframes gg-pop { from { opacity: 0; transform: scale(.9) translateY(8px); } to { opacity: 1; transform: none; } }

/* ---------------------------------------------------------------- rotate hint (the game shows it on phones held upright during play) */
#rotate { z-index: 40; background: #04050c; }      /* opaque: the Paused card under it must never show through */
#rotate .rotate-card { display: grid; justify-items: center; gap: 22px; padding: 24px; text-align: center; }
#rotate .rotate-card p { margin: 0; max-width: 18em; font-size: 20px; font-weight: 700; line-height: 1.35; }
#rotate .phone-icon {
  position: relative; width: 62px; height: 106px; border: 5px solid var(--accent); border-radius: 14px;
  box-shadow: 0 0 24px -4px var(--accent); animation: gg-turn 2.6s ease-in-out infinite;
}
#rotate .phone-icon::before { content: ""; position: absolute; top: 6px; left: 50%; width: 16px; height: 4px; margin-left: -8px; border-radius: 2px; background: var(--accent); opacity: .8; }
#rotate .phone-icon::after { content: ""; position: absolute; bottom: 7px; left: 50%; width: 12px; height: 12px; margin-left: -6px; border: 2px solid var(--accent); border-radius: 50%; opacity: .6; }
@keyframes gg-turn { 0%, 15% { transform: rotate(0); } 45%, 80% { transform: rotate(-90deg); } 100% { transform: rotate(0); } }

/* ---------------------------------------------------------------- mic card (mic blocked or missing) and the log box */
#micCard { z-index: 30; background: rgba(2, 3, 10, .82); }   /* above #pause (10), below #rotate (40) */
#micCard .sub { color: var(--fg); font-size: 16px; line-height: 1.45; text-align: left; }
#logBox { z-index: 60; background: rgba(2, 3, 10, .9); }     /* above the menu (20), the rotate screen (40) and the toast (50) */
#logBox .card { display: flex; flex-direction: column; width: min(680px, 100%); }
#logText {
  display: block; width: 100%; height: min(42vh, 320px); min-height: 90px; margin: 4px 0 0; padding: 10px 12px; resize: none;
  font: 12px/1.4 ui-monospace, Consolas, "Courier New", monospace; color: var(--fg); background: rgba(0, 0, 0, .35);
  border: 1px solid var(--line); border-radius: 10px; user-select: text; -webkit-user-select: text; white-space: pre; overflow: auto;
}

/* ---------------------------------------------------------------- toast (small message, top centre, under the score) */
.toast {
  position: fixed; left: 50%; top: calc(var(--st) + 64px); transform: translateX(-50%); z-index: 50; max-width: calc(100% - 32px);
  padding: 9px 18px; border-radius: 999px; background: rgba(8, 10, 24, .92); border: 1px solid var(--accent); color: var(--fg);
  font-size: 14px; font-weight: 600; line-height: 1.3; text-align: center; pointer-events: none; animation: gg-toast .22s ease-out both;
}
@keyframes gg-toast { from { opacity: 0; transform: translateX(-50%) translateY(-8px); } to { opacity: 1; transform: translateX(-50%); } }

/* ---------------------------------------------------------------- phone landscape: everything compact */
@media (orientation: landscape) and (max-height: 520px) {
  :root { --hedge: 6px; }
  .overlay { padding-top: calc(6px + var(--st)); padding-bottom: calc(6px + var(--sb)); }
  .overlay .card { padding: 14px 20px; border-radius: 16px; }
  .overlay h2 { font-size: 26px; margin-bottom: 2px; }
  .overlay .sub { margin: 2px 0 10px; font-size: 14px; }
  .overlay .stats { font-size: 14px; line-height: 1.55; margin-top: 4px; }
  .overlay .btns { margin-top: 10px; }
  .overlay .go, .overlay .btn { min-height: 46px; }
  .overlay .go { font-size: 18px; }
  .overlay .row { margin-top: 8px; }
  .face-canvas { height: 110px; margin-bottom: 4px; }
  #over .card { display: grid; grid-template-columns: minmax(130px, 36%) 1fr; column-gap: 18px; align-items: center; width: min(640px, 100%); text-align: left; }
  #over .face-canvas { grid-column: 1; grid-row: 1 / span 5; margin: 0; }
  #over h2, #over .overline, #over .stats, #over .btns, #over .row { grid-column: 2; }
  .overline { font-size: 17px; margin: 0 0 6px; -webkit-line-clamp: 2; line-clamp: 2; }
  #logText { height: calc(100vh - 150px); min-height: 70px; }
  #logBox .sub { display: none; }
  #rotate .rotate-card { gap: 12px; }
  #rotate .phone-icon { width: 40px; height: 68px; border-width: 4px; }
}
@media (max-width: 380px) { .overlay .card { padding: 18px 16px; } .overlay .btns { flex-direction: column; } }
@media (prefers-reduced-motion: reduce) {
  .overlay .card, .toast, #rotate .phone-icon { animation: none; }
  .hudbtn, .overlay .go, .overlay .btn { transition: none; }
}
