@font-face { font-family: 'Fredoka'; src: url('fonts/fredoka-latin-500-normal.woff2') format('woff2'); font-weight: 500; font-display: swap; }
@font-face { font-family: 'Fredoka'; src: url('fonts/fredoka-latin-700-normal.woff2') format('woff2'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Space Mono'; src: url('fonts/space-mono-latin-400-normal.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Space Mono'; src: url('fonts/space-mono-latin-700-normal.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --slime: #9BFF3D; --pink: #FF5CC0; --cyan: #3DF2FF; --gold: #FFD23D;
  --ink: #121019; --ink2: #1D1A29; --text: #EDEAF5; --snow: #DCE9F7;
  --fs: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--ink); color: var(--text); overflow: hidden; }
body { font: 500 var(--fs)/1.35 'Fredoka', system-ui, sans-serif; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; }
body.big { --fs: 19px; }
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }

#app {
  position: fixed; inset: 0; display: grid;
  grid-template-rows: auto 1fr auto; grid-template-columns: 1fr;
  grid-template-areas: "hud" "stage" "pad";
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
#hud { grid-area: hud; display: flex; align-items: center; gap: 10px; padding: 8px 10px; background: var(--ink2); border-bottom: 4px solid #000; min-width: 0; }
#hudMid { flex: 1; min-width: 0; text-align: center; }
#hourTitle { font-weight: 700; font-size: 1.15em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#legend { font: 400 0.78em/1.3 'Space Mono', monospace; color: #CFC9E3; display: flex; flex-wrap: wrap; justify-content: center; gap: 2px 10px; min-height: 1.3em; }
#legend .soon { color: var(--gold); font-weight: 700; }
#stats { display: flex; flex-direction: column; align-items: flex-end; font: 400 0.72em/1.1 'Space Mono', monospace; min-width: 64px; }
#stats b { font: 700 1.9em/1 'Space Mono', monospace; color: var(--slime); }
#stats small { color: #CFC9E3; font-size: 1em; }
.icon { width: 48px; height: 48px; border: 3px solid #000; border-radius: 12px; background: var(--pink); color: #000; font-size: 22px; font-weight: 700; box-shadow: 3px 3px 0 #000; flex: none; }

#stage { grid-area: stage; position: relative; min-height: 0; touch-action: none; }
#board { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#toast { position: absolute; left: 50%; top: 10px; transform: translateX(-50%); max-width: calc(100% - 24px); background: var(--gold); color: #000; border: 3px solid #000; border-radius: 12px; padding: 6px 12px; font-weight: 700; box-shadow: 3px 3px 0 #000; opacity: 0; transition: opacity .25s; pointer-events: none; text-align: center; }
#toast.show { opacity: 1; }

#pad { grid-area: pad; display: flex; gap: 10px; justify-content: center; padding: 10px; background: var(--ink2); border-top: 4px solid #000; }
.padBtn { flex: 1; max-width: 140px; min-height: 56px; border: 3px solid #000; border-radius: 14px; background: var(--cyan); color: #000; font-weight: 700; box-shadow: 4px 4px 0 #000; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; touch-action: manipulation; }
.padBtn.big { background: var(--slime); max-width: 170px; }
.padBtn .ic { font-size: 1.3em; }
.padBtn:active, .btn:active, .icon:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 #000; }

@media (orientation: landscape) and (max-height: 600px) {
  #app { grid-template-columns: 1fr auto; grid-template-rows: auto 1fr; grid-template-areas: "hud hud" "stage pad"; }
  #pad { flex-direction: column; border-top: 0; border-left: 4px solid #000; justify-content: center; width: 120px; }
  .padBtn { flex: none; width: 96px; }
  #hud { padding: 4px 10px; }
  .icon { width: 44px; height: 44px; }
}

.screen { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; padding: max(16px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); background: rgba(18, 16, 25, .78); z-index: 10; overflow-y: auto; }
.screen.show { display: flex; }
#title { background: transparent; }
.card { width: min(440px, 100%); max-height: 100%; overflow-y: auto; background: var(--ink2); border: 4px solid #000; border-radius: 20px; padding: 20px; box-shadow: 6px 6px 0 var(--pink); margin: auto; }
.card h2 { margin: 0 0 10px; font-size: 1.6em; }
.titleCard { text-align: center; background: rgba(29, 26, 41, .92); }
h1 { margin: 0; font-size: 2.6em; line-height: .95; color: var(--gold); text-shadow: 3px 3px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000; }
h1 span { color: var(--cyan); }
.tag { font-family: 'Space Mono', monospace; font-size: .85em; color: #CFC9E3; }
.menu { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.menu.row { flex-direction: row; justify-content: center; flex-wrap: wrap; }
.btn { min-height: 50px; padding: 8px 18px; border: 3px solid #000; border-radius: 14px; background: #EDEAF5; color: #000; font: 700 1em 'Space Mono', monospace; text-transform: uppercase; box-shadow: 4px 4px 0 #000; }
.btn.primary { background: var(--slime); }
.btn:focus-visible, .padBtn:focus-visible, .icon:focus-visible, .hourBtn:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.madeby { margin: 16px 0 0; font: 400 .72em 'Space Mono', monospace; color: #A9A2C2; }
.madeby img { display: inline-block; height: 26px; width: auto; }

#hourGrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.hourBtn { min-height: 64px; border: 3px solid #000; border-radius: 12px; background: var(--cyan); color: #000; font-weight: 700; box-shadow: 3px 3px 0 #000; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; }
.hourBtn small { font: 400 .7em 'Space Mono', monospace; }
.hourBtn.done { background: var(--slime); }
.hourBtn.locked { background: #4A4560; color: #A9A2C2; cursor: not-allowed; }
.hint, .help { font: 400 .8em 'Space Mono', monospace; color: #CFC9E3; }

.note { background: #F4ECD8; color: #1D1A29; box-shadow: 6px 6px 0 var(--gold); position: relative; transform: rotate(-1deg); }
.note h2 { font-size: 1.3em; }
.note p { font-size: 1.05em; }
.note .help { color: #4A4560; border-top: 2px dashed #B5AA8E; padding-top: 10px; }
.pin { position: absolute; top: -12px; left: 50%; width: 22px; height: 22px; margin-left: -11px; border-radius: 50%; background: var(--pink); border: 3px solid #000; }

.set { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 10px 0; min-height: 44px; }
.set input[type=range] { flex: 1; max-width: 220px; height: 32px; accent-color: var(--slime); }
.set.check { justify-content: flex-start; }
.set.check input { width: 26px; height: 26px; accent-color: var(--slime); flex: none; }
.helpList { padding-left: 18px; margin: 0; }
.helpList li { margin: 6px 0; }
.star { font-size: 1.2em; color: var(--gold); font-weight: 700; }
#winText { font-family: 'Space Mono', monospace; }
body.onTitle #hud, body.onTitle #pad { visibility: hidden; }
.note .menu.row { position: sticky; bottom: -20px; background: #F4ECD8; padding: 8px 0 4px; margin-bottom: -4px; }
@media (max-height: 500px) {
  .card { padding: 14px 16px; }
  .card h2 { font-size: 1.2em; margin-bottom: 4px; }
  .note p { font-size: .92em; margin: 6px 0; }
  .note .help { font-size: .72em; padding-top: 6px; }
  .menu { margin-top: 8px; }
  .btn { min-height: 44px; }
}
