:root {
  --ink: #fff8ec;
  --ink-dim: #e8dcc8;
  --accent: #ffb347;
  --accent-2: #ff6f91;
  --glass: rgba(24, 18, 30, 0.62);
  --glass-border: rgba(255, 255, 255, 0.14);
  --danger: #ff4d4d;
  --good: #7be27b;
  --font: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #1a1420; color: var(--ink); font-family: var(--font);
  user-select: none;
}
#game, #game canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#game canvas { cursor: crosshair; }
.hidden { display: none !important; }

#loading {
  position: fixed; inset: 0; display: grid; place-items: center;
  background: #1a1420; font-size: 28px; z-index: 50;
}

/* ---------------- HUD ---------------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 5; }
.panel-glass {
  background: var(--glass); border: 1px solid var(--glass-border);
  border-radius: 14px; padding: 10px 14px; backdrop-filter: blur(4px);
}
#hud-left { position: absolute; top: 14px; left: 14px; min-width: 250px; }
#hud-name { font-weight: 700; font-size: 20px; letter-spacing: .5px; margin-bottom: 6px; color: var(--accent); }
.hud-row { display: flex; align-items: center; gap: 10px; margin: 5px 0; }
.hud-label { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--ink-dim); width: 92px; flex: none; }
#hud-fish, #hud-ammo, #hud-streak { display: flex; gap: 3px; align-items: center; }
.icon { width: 26px; height: 18px; position: relative; }
.icon svg { width: 100%; height: 100%; display: block; }
.fish-icon .fill { position: absolute; inset: 0; overflow: hidden; }
.fish-icon .fill svg { width: 26px; }
.ammo-count { font-weight: 700; margin-left: 4px; }
.streak-pip { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255,255,255,.4); }
.streak-pip.on { background: linear-gradient(135deg, #ff004c, #ff9900, #ffee00, #33ff00, #0099ff, #6633ff); border-color: #fff; }
.bar { width: 120px; height: 10px; background: rgba(255,255,255,.15); border-radius: 6px; overflow: hidden; }
.bar.small { width: 70px; height: 7px; }
.bar-fill { height: 100%; width: 0%; background: var(--good); transition: width .08s linear, background .2s; }

#hud-top { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); text-align: center; }
#hud-timer { font-size: 30px; font-weight: 800; text-shadow: 0 2px 6px rgba(0,0,0,.6); font-variant-numeric: tabular-nums; }
#hud-timelimit { font-size: 12px; color: var(--ink-dim); text-shadow: 0 1px 3px #000; }
#hud-timelimit.warn { color: var(--danger); font-weight: 700; animation: blink .5s infinite alternate; }
#hud-goal-arrow { font-size: 34px; color: #ffe066; text-shadow: 0 0 10px #ffb700; margin-top: 4px; display: inline-block; }
#hud-dog { display: flex; align-items: center; gap: 6px; justify-content: center; margin-top: 6px;
  font-size: 12px; background: var(--glass); border-radius: 20px; padding: 3px 10px; }
#hud-dog.alert { background: rgba(160, 20, 20, .75); animation: blink .3s infinite alternate; }
#hud-dog-eye { font-size: 14px; }

#hud-right { position: absolute; top: 14px; right: 14px; text-align: right; }
#hud-enemies { font-size: 16px; }
#hud-enemies b { color: var(--accent); font-size: 22px; }
#hud-enemy-break { font-size: 12px; color: var(--ink-dim); margin-bottom: 6px; }
#hud-objectives { font-size: 13px; margin: -2px 0 6px; }
#hud-objectives div { margin: 2px 0; }
#hud-objectives .done { color: var(--good); }
#hud-objectives b { color: var(--accent); }
#minimap { display: block; border-radius: 8px; background: rgba(0,0,0,.35); }

#crosshair { position: absolute; left: 50%; top: 46%; width: 6px; height: 6px; margin: -3px; border-radius: 50%;
  background: rgba(255,255,255,.75); box-shadow: 0 0 4px #000; }
#hud-prompt { position: absolute; bottom: 90px; left: 50%; transform: translateX(-50%);
  background: var(--glass); padding: 8px 16px; border-radius: 10px; font-size: 16px; border: 1px solid var(--glass-border); }
#hud-prompt b { color: var(--accent); }
#hud-room { position: absolute; top: 28%; left: 50%; transform: translateX(-50%); font-size: 34px; font-weight: 800;
  letter-spacing: 3px; text-transform: uppercase; text-shadow: 0 3px 12px #000; animation: fadeout 2.2s forwards; }
#hud-feed { position: absolute; bottom: 24px; left: 18px; display: flex; flex-direction: column-reverse; gap: 4px; max-width: 46vw; }
.feed-item { background: var(--glass); padding: 5px 12px; border-radius: 8px; font-size: 14px; animation: fadeout 4s forwards; }
#hud-nyan-banner { position: absolute; bottom: 140px; left: 50%; transform: translateX(-50%); font-size: 22px; font-weight: 800;
  padding: 8px 18px; border-radius: 12px; color: #fff;
  background: linear-gradient(90deg, #ff004c, #ff9900, #e8d000, #2bd600, #0099ff, #6633ff);
  text-shadow: 0 2px 4px rgba(0,0,0,.6); animation: pulse .6s infinite alternate; }
#labels { position: absolute; inset: 0; overflow: hidden; }
.label { position: absolute; transform: translate(-50%, -100%); white-space: nowrap; font-weight: 700; pointer-events: none; }
.label.bubble { background: #fff; color: #222; padding: 4px 10px; border-radius: 12px; font-size: 14px; box-shadow: 0 2px 6px rgba(0,0,0,.4); }
.label.bubble::after { content: ""; position: absolute; left: 50%; bottom: -6px; margin-left: -6px;
  border: 6px solid transparent; border-top-color: #fff; border-bottom: 0; }
.label.pop { font-size: 26px; color: #ffe14d; -webkit-text-stroke: 1.5px #7a2a00; text-shadow: 0 3px 0 #7a2a00; }
.label.zzz { font-size: 30px; color: #cfe3ff; text-shadow: 0 0 8px #335; }
.label.hit { font-size: 24px; color: #ff4d4d; -webkit-text-stroke: 1.2px #3a0000; text-shadow: 0 2px 0 #3a0000; }
.label.alert { font-size: 34px; color: #ff3b3b; -webkit-text-stroke: 1.5px #400; }
.label.nametag { font-size: 12px; color: #fff; background: rgba(0,0,0,.45); padding: 1px 6px; border-radius: 6px; }
#vignette { position: absolute; inset: 0; opacity: 0; background: radial-gradient(ellipse at center, transparent 45%, rgba(220,0,0,.75) 100%); transition: opacity .35s; }
#nyan-overlay { position: absolute; inset: 0; opacity: 0; transition: opacity .3s;
  background: linear-gradient(180deg, rgba(255,0,76,.12), rgba(255,153,0,.1), rgba(232,208,0,.1), rgba(43,214,0,.1), rgba(0,153,255,.1), rgba(102,51,255,.12)); }
#nyan-overlay.on { opacity: 1; animation: hue 1s linear infinite; }
.edge { position: absolute; top: 0; bottom: 0; width: 14vw; opacity: 0; transition: opacity .1s; }
#edge-left { left: 0; background: linear-gradient(90deg, rgba(255,224,102,.28), transparent); }
#edge-right { right: 0; background: linear-gradient(270deg, rgba(255,224,102,.28), transparent); }
#click-to-play { position: absolute; top: 112px; left: 50%; transform: translateX(-50%); background: var(--glass);
  padding: 6px 14px; border-radius: 10px; font-size: 13px; color: var(--ink-dim); }

@keyframes blink { from { opacity: 1; } to { opacity: .45; } }
@keyframes fadeout { 0% { opacity: 0; } 10% { opacity: 1; } 75% { opacity: 1; } 100% { opacity: 0; } }
@keyframes pulse { from { transform: translateX(-50%) scale(1); } to { transform: translateX(-50%) scale(1.06); } }
@keyframes hue { from { filter: hue-rotate(0deg); } to { filter: hue-rotate(360deg); } }

/* ---------------- MENUS ---------------- */
#menu-root { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
.screen { position: absolute; inset: 0; pointer-events: auto; overflow-y: auto; padding: 24px 16px 40px;
  background: radial-gradient(ellipse at 30% 20%, rgba(255,179,71,.18), transparent 60%),
              radial-gradient(ellipse at 80% 90%, rgba(255,111,145,.16), transparent 60%),
              rgba(20, 14, 28, .82); }
#screen-pause, #screen-end { background: rgba(14, 10, 20, .72); }
.title { text-align: center; font-size: clamp(34px, 6vw, 64px); margin: 6px 0 0; letter-spacing: 4px; font-weight: 900;
  color: #fff; text-shadow: 0 4px 0 #b4532a, 0 8px 18px rgba(0,0,0,.6); }
.title span { color: var(--accent); }
.title.small { font-size: clamp(28px, 4vw, 44px); }
.subtitle { text-align: center; color: var(--ink-dim); margin: 6px 0 18px; }
.select-layout { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; max-width: 1040px; margin: 0 auto; }
.card { background: var(--glass); border: 1px solid var(--glass-border); border-radius: 18px; padding: 16px; }
.preview-card { flex: 1 1 420px; max-width: 560px; }
.side-card { flex: 1 1 320px; max-width: 420px; display: flex; flex-direction: column; gap: 10px; }
.preview-slot { width: 100%; aspect-ratio: 4 / 3; border-radius: 12px; overflow: hidden;
  background: radial-gradient(circle at 50% 40%, #fff1d6, #f2b880 70%, #c9845a); }
.preview-slot canvas { width: 100% !important; height: 100% !important; display: block; }
.hat-picker { display: flex; align-items: center; justify-content: center; gap: 14px; margin: 12px 0 8px; }
#hat-name { font-size: 22px; font-weight: 800; min-width: 200px; text-align: center; }
.arrow-btn { background: var(--accent); color: #2a1a10; border: 0; width: 40px; height: 40px; border-radius: 50%; font-size: 16px; cursor: pointer; }
.arrow-btn:hover { filter: brightness(1.1); }
#hat-grid { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.hat-chip { background: rgba(255,255,255,.08); color: var(--ink); border: 1px solid var(--glass-border); border-radius: 20px;
  padding: 4px 10px; font-size: 13px; cursor: pointer; font-family: var(--font); }
.hat-chip.on { background: var(--accent); color: #2a1a10; font-weight: 700; }
.sub-picker { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.picker-label { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; color: var(--ink-dim); }
.arrow-btn.small { width: 30px; height: 30px; font-size: 12px; }
.picker-name { font-size: 18px; font-weight: 800; min-width: 150px; text-align: center; }
#fur-grid { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; margin-top: 8px; }
.fur-swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid rgba(255,255,255,.35); cursor: pointer; padding: 0;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.25); }
.fur-swatch:hover { transform: scale(1.08); }
.fur-swatch.on { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(255,179,71,.45); }
#build-grid { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.fur-row { margin-top: 10px; text-align: center; font-size: 14px; }
.soon { color: var(--ink-dim); font-size: 12px; font-style: italic; }
.field-label { font-size: 13px; color: var(--ink-dim); text-transform: uppercase; letter-spacing: 1px; }
.name-row { display: flex; gap: 8px; }
#cat-name { flex: 1; font-size: 22px; padding: 8px 12px; border-radius: 10px; border: 2px solid var(--glass-border);
  background: rgba(0,0,0,.35); color: #fff; font-family: var(--font); user-select: text; min-width: 0; }
#cat-name:focus { outline: none; border-color: var(--accent); }
.btn { font-family: var(--font); font-size: 16px; padding: 10px 16px; border-radius: 12px; border: 1px solid var(--glass-border);
  background: rgba(255,255,255,.1); color: var(--ink); cursor: pointer; font-weight: 700; }
.btn:hover { background: rgba(255,255,255,.18); }
.btn.primary { background: linear-gradient(180deg, #ffc46b, #ff9a3c); color: #2a1a10; border: 0; box-shadow: 0 4px 0 #b4532a; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.big { font-size: 20px; padding: 14px; }
.btn.small { padding: 6px 10px; font-size: 18px; }
h3 { margin: 8px 0 2px; font-size: 15px; color: var(--accent); text-transform: uppercase; letter-spacing: 1px; }
.leaderboard { margin: 0; padding-left: 26px; font-size: 14px; max-height: 220px; overflow-y: auto; }
.leaderboard li { padding: 3px 0; border-bottom: 1px dashed rgba(255,255,255,.08); }
.leaderboard li .t { float: right; font-variant-numeric: tabular-nums; font-weight: 700; }
.leaderboard li .h { color: var(--ink-dim); font-size: 12px; }
.leaderboard li.me { color: #ffe066; }
.leaderboard .empty { list-style: none; margin-left: -26px; color: var(--ink-dim); font-style: italic; }
.controls summary { cursor: pointer; color: var(--accent); font-weight: 700; margin-top: 4px; }
.controls-grid { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 13px; margin-top: 8px; }
.controls-grid kbd { background: rgba(255,255,255,.14); border-radius: 5px; padding: 1px 6px; font-family: var(--font); font-size: 12px; white-space: nowrap; }
.level-picker { display: grid; grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)); gap: 8px; }
.level-card { text-align: left; font-family: var(--font); color: var(--ink); background: rgba(255,255,255,.07);
  border: 2px solid var(--glass-border); border-radius: 12px; padding: 8px 10px; cursor: pointer; }
.level-card:hover { background: rgba(255,255,255,.12); }
.level-card.on { border-color: var(--accent); background: rgba(255,179,71,.16); }
.level-card .num { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--ink-dim); }
.level-card .nm { display: block; font-size: 17px; font-weight: 800; }
.level-card .best { display: block; font-size: 12px; color: var(--accent); margin-top: 2px; }
.check-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-dim); cursor: pointer; }
.check-row input, .setting input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }
.setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; }
.setting input[type=range] { flex: 1; max-width: 200px; accent-color: var(--accent); }
.mouse-status { font-size: 12px; color: var(--ink-dim); background: rgba(0,0,0,.25); border-radius: 8px; padding: 6px 10px; user-select: text; line-height: 1.4; }
.mouse-status b { color: var(--ink); }
.center-text { text-align: center; margin-top: 10px; font-size: 20px; font-weight: 800; }
.end-card { max-width: 520px; margin: 0 auto; display: flex; flex-direction: column; gap: 8px; }
#end-time { font-size: 30px; text-align: center; font-weight: 800; }
#end-time small { display: block; font-size: 14px; color: var(--ink-dim); font-weight: 400; }
.end-buttons { display: flex; gap: 10px; justify-content: center; margin-top: 8px; }

@media (max-width: 700px) {
  #hud-left { min-width: 0; transform: scale(.82); transform-origin: top left; }
  #hud-right { transform: scale(.75); transform-origin: top right; }
}
