/* Cat & Fish – old-school arcade UI around the canvas (fixed 1280×720 world, letterboxed). */
@font-face { font-family: 'Pixel'; src: url(assets/pixel-latin.woff2) format('woff2'); font-display: swap;
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2190-2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Pixel'; src: url(assets/pixel-latin-ext.woff2) format('woff2'); font-display: swap;
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1E00-1E9F, U+20A0-20AB, U+20AD-20C4, U+2C60-2C7F, U+A720-A7FF; }

:root {
  --yellow: #ffd23f;
  --cyan: #3ee6ff;
  --pink: #ff4fd8;
  --green: #5cff6c;
  --red: #ff3b3b;
  --white: #ffffff;
  --grey: #9a9a9a;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: #000; color: var(--white); overflow: hidden;
  font: 14px/1.6 'Pixel', ui-monospace, monospace; -webkit-font-smoothing: none; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }

#stage { position: fixed; inset: 0; display: grid; place-items: center; }
#game { display: block; width: min(100vw, calc(100vh * 16 / 9)); height: auto; aspect-ratio: 16 / 9; image-rendering: pixelated; }
@supports (height: 100dvh) { #game { width: min(100vw, calc(100dvh * 16 / 9)); } }

/* HUD: plain pixel text on black bars */
#hud { position: absolute; left: 0; right: 0; top: 0; display: flex; justify-content: space-between; gap: 10px; z-index: 5; pointer-events: none;
  padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 0 max(10px, env(safe-area-inset-left)); font-size: 13px; }
.hud-left, .hud-right { display: flex; gap: 6px; align-items: center; }
.hud-left > span, #hudHearts { background: #000; padding: 6px 10px; display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
#hudLevel { color: var(--yellow); }
.fish-ic { width: 24px; height: auto; }
#hudHearts { font-size: 14px; letter-spacing: 2px; }
#hudHearts .lost { opacity: .2; }
.icon-btn { pointer-events: auto; width: 34px; height: 34px; background: #000; color: var(--white); border: 2px solid var(--white); font-size: 12px; }
.icon-btn.off { color: var(--grey); border-color: var(--grey); text-decoration: line-through; }

#banner { position: absolute; left: 50%; top: 26%; transform: translateX(-50%); z-index: 6; pointer-events: none; white-space: nowrap;
  font-size: clamp(22px, 4.5vw, 48px); color: var(--yellow); text-shadow: 4px 4px 0 #b3006b; animation: blink-in .6s steps(4); }
@keyframes blink-in { 0%, 50% { opacity: 0; } 25%, 75%, 100% { opacity: 1; } }

/* Screens: black, centred, nothing but pixel text */
.screen { position: absolute; inset: 0; z-index: 10; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px;
  padding: 24px; background: rgba(0, 0, 0, .9); text-align: center; overflow: auto; }
.screen[hidden], #hud[hidden], #touch[hidden], #banner[hidden], #rotate[hidden] { display: none; }
.back { position: absolute; left: 18px; top: 16px; color: var(--grey); text-decoration: none; font-size: 11px; }
.back:hover { color: var(--white); }
.title { margin: 0; font-size: clamp(30px, 6.5vw, 64px); font-weight: 400; line-height: 1.1; color: var(--yellow); text-shadow: 5px 5px 0 #b3006b; letter-spacing: 2px; }
.title span { color: var(--cyan); text-shadow: 5px 5px 0 #0055aa; }
.hero-cat { width: 72px; height: auto; image-rendering: pixelated; animation: hop 1s steps(2) infinite; }
@keyframes hop { 50% { transform: translateY(-8px); } }
.press { font-size: clamp(13px, 2vw, 18px); color: var(--white); padding: 6px 10px; }
.press:hover { color: var(--yellow); }
.blink { animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.big { margin: 0; font-size: clamp(26px, 5.5vw, 54px); font-weight: 400; color: var(--red); text-shadow: 5px 5px 0 #550000; }
#pause .big { color: var(--yellow); text-shadow: 5px 5px 0 #b3006b; }
.help { color: var(--grey); font-size: 10px; margin: 0; }
.credit { color: #666; font-size: 9px; margin: 0; }
.result { margin: 0; font-size: clamp(11px, 1.6vw, 15px); }
.result b { color: var(--yellow); font-weight: 400; }

/* hi-score table */
.hiscores { width: min(560px, 100%); }
.hiscores h2 { margin: 0 0 10px; font-size: 14px; font-weight: 400; color: var(--cyan); }
.hiscores ol { list-style: none; margin: 0; padding: 0; font-size: 12px; }
.hiscores li { display: grid; grid-template-columns: 4.5em 1fr 4.5em 6em; gap: 10px; padding: 3px 0; text-align: left; font-variant-numeric: tabular-nums; }
.hiscores li:nth-child(1) { color: var(--yellow); } .hiscores li:nth-child(2) { color: var(--cyan); } .hiscores li:nth-child(3) { color: var(--pink); }
.hiscores li.me { color: var(--green); position: relative; }
.hiscores li.me::before { content: ">"; position: absolute; left: -1.6em; animation: blink 1s steps(1) infinite; }
.hiscores li.empty { display: block; text-align: center; color: var(--grey); }
.hiscores .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-transform: uppercase; }
.hiscores .sc, .hiscores .tm { text-align: right; }

/* name entry */
#saveForm { display: grid; gap: 8px; justify-items: center; }
#saveForm[hidden] { display: none; }
.new-hi { margin: 0; color: var(--green); font-size: 14px; }
#saveForm label { font-size: 12px; }
.name-row { display: flex; gap: 8px; }
#saveForm input { font: inherit; font-size: 14px; width: min(340px, 64vw); padding: 10px; background: #000; color: var(--yellow); border: 3px solid var(--white);
  text-transform: uppercase; text-align: center; outline: none; user-select: text; -webkit-user-select: text; caret-color: var(--yellow); }
#saveForm input:focus { border-color: var(--yellow); }
#saveForm input::placeholder { color: #555; }
#btnSave { padding: 10px 16px; background: var(--white); color: #000; border: 3px solid var(--white); }
#btnSave:hover, #btnSave:focus { background: var(--yellow); border-color: var(--yellow); outline: none; }
#saveForm small { color: #666; font-size: 9px; }
.form-msg { margin: 0; min-height: 1.4em; font-size: 11px; }
.form-msg.ok { color: var(--green); } .form-msg.err { color: var(--red); }

/* menu-like choices with a blinking cursor */
.choices { display: flex; gap: 28px; flex-wrap: wrap; justify-content: center; }
#pause .choices { flex-direction: column; gap: 14px; }
.choices button { font-size: 14px; padding: 4px 0 4px 22px; position: relative; color: var(--white); }
.choices button:hover, .choices button:focus-visible { color: var(--yellow); outline: none; }
.choices button:hover::before, .choices button:focus-visible::before { content: '>'; position: absolute; left: 0; animation: blink 1s steps(1) infinite; }

/* touch vs keyboard hints */
.tap-hint { display: none; }
@media (pointer: coarse) { .key-hint { display: none; } .tap-hint { display: inline; } }

/* touch controls: square, chunky */
#touch { position: absolute; inset: auto 0 0 0; z-index: 6; display: flex; justify-content: space-between; align-items: flex-end; pointer-events: none;
  padding: 0 max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left)); }
#touch > div { display: flex; gap: 10px; align-items: flex-end; pointer-events: auto; }
#touch button { width: 74px; height: 74px; border: 3px solid rgba(255,255,255,.7); background: rgba(0,0,0,.45); color: #fff; font-size: 20px; touch-action: none; }
#touch button.small { width: 54px; height: 54px; font-size: 14px; }
#touch button.jump { width: 92px; height: 92px; font-size: 13px; border-color: var(--yellow); color: var(--yellow); }
#touch button.down { background: var(--yellow); color: #000; }

#rotate { position: absolute; inset: 0; z-index: 20; display: grid; place-items: center; background: #000; color: var(--yellow); font-size: 14px; padding: 20px; text-align: center; }

@media (max-height: 520px) {
  .screen { gap: 10px; padding: 12px; justify-content: flex-start; }
  .hero-cat { width: 48px; }
  .hiscores ol { font-size: 10px; }
}
@media (prefers-reduced-motion: reduce) { .blink, .hero-cat, .hiscores li.me::before { animation: none; } }
