:root {
  --accent: #f2c023;
  --panel: rgba(12, 14, 16, 0.82);
  --text: #e9e4d6;
  --red: #e0352b;
  --green: #3ccf6b;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #000; color: var(--text);
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif; user-select: none; }
canvas#game { display: block; width: 100vw; height: 100vh; }
.hidden { display: none !important; }
kbd { display: inline-block; min-width: 1.6em; padding: 0.1em 0.45em; margin: 0 0.12em; border-radius: 5px;
  background: #f4efe2; color: #111; font: bold 0.85em/1.4 monospace; text-align: center; box-shadow: 0 2px 0 #8d887a; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
#crosshair { position: absolute; left: 50%; top: 50%; width: 6px; height: 6px; margin: -3px 0 0 -3px;
  border-radius: 50%; background: rgba(255,255,255,0.75); box-shadow: 0 0 4px #000; }
#prompt { position: absolute; left: 50%; top: calc(50% + 34px); transform: translateX(-50%);
  padding: 8px 16px; border-radius: 8px; background: var(--panel); font-size: 18px; opacity: 0;
  transition: opacity 0.15s; white-space: nowrap; }
#objective { position: absolute; left: 20px; top: 20px; max-width: min(420px, calc(100vw - 40px)); padding: 10px 14px;
  border-left: 4px solid var(--accent); background: var(--panel); border-radius: 0 8px 8px 0; font-size: 16px; line-height: 1.35; }
#objective .label { display: block; font-size: 11px; letter-spacing: 0.2em; color: var(--accent); font-weight: bold; }
#objective.flash { animation: flash 1.2s ease; }
@keyframes flash { 0%, 40% { background: rgba(242, 192, 35, 0.45); } 100% { background: var(--panel); } }
#inventory { position: absolute; right: 20px; top: 20px; display: flex; gap: 8px; }
#inventory .chip { padding: 8px 12px; border-radius: 8px; background: var(--panel); font-size: 16px; border: 1px solid rgba(255,255,255,0.15); }
#stamina { position: absolute; left: 50%; bottom: 36px; width: 220px; height: 8px; margin-left: -110px;
  background: rgba(0,0,0,0.6); border-radius: 4px; overflow: hidden; transition: opacity 0.4s; opacity: 0; }
#stamina-fill { height: 100%; width: 100%; background: #8fd3ff; }
#stamina-fill.low { background: var(--red); }
#toast { position: absolute; left: 50%; top: 22%; transform: translate(-50%, -10px); padding: 12px 22px; border-radius: 10px;
  background: var(--panel); font-size: 20px; opacity: 0; transition: opacity 0.3s, transform 0.3s; text-align: center; max-width: 80vw; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#danger { position: fixed; inset: 0; pointer-events: none; opacity: 0; transition: opacity 0.3s;
  background: radial-gradient(ellipse at center, transparent 45%, rgba(150, 0, 0, 0.55) 100%); }

/* ---------- locker ---------- */
#locker-view { position: fixed; inset: 0; pointer-events: none; }
#locker-view .slats { position: absolute; inset: 0;
  background:
    linear-gradient(to right, #0c0f0e 0 14%, transparent 14% 86%, #0c0f0e 86%),
    repeating-linear-gradient(to bottom, #111614 0 46px, transparent 46px 64px); }

/* ---------- note ---------- */
#note { position: fixed; right: 4vw; top: 50%; transform: translateY(-50%); width: min(380px, 90vw); pointer-events: none; }
#note-paper { background: #ece3c8; color: #2a2018; padding: 22px 26px; border-radius: 3px; transform: rotate(-1.2deg);
  box-shadow: 0 12px 40px rgba(0,0,0,0.7); font-family: "Marker Felt", "Comic Sans MS", cursive; font-size: 19px; line-height: 1.35;
  background-image: repeating-linear-gradient(to bottom, transparent 0 27px, rgba(80,110,170,0.25) 27px 28px); }
#note-paper h3 { margin: 0 0 10px; font-size: 24px; }
#note-paper p { margin: 0; }
.note-hint { margin-top: 12px; text-align: center; font-size: 15px; text-shadow: 0 1px 3px #000; }

/* ---------- keypad ---------- */
#keypad { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,0.45); }
.keypad-box { width: min(340px, calc(100vw - 32px)); padding: 20px; border-radius: 16px; background: #2a2e31;
  border: 3px solid #44494d; box-shadow: 0 20px 60px #000, inset 0 2px 0 rgba(255,255,255,0.08); text-align: center; }
.keypad-title { font: bold 20px monospace; letter-spacing: 0.25em; color: var(--accent); margin-bottom: 12px; }
.keypad-slots { display: flex; justify-content: center; gap: 12px; margin-bottom: 10px; }
.slot { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.slot span { display: grid; place-items: center; width: 64px; height: 72px; border-radius: 10px; background: #071a10;
  border: 4px solid var(--c); color: #b9ffcf; font: bold 42px monospace; }
.slot label { font: bold 12px sans-serif; text-transform: uppercase; color: var(--c); letter-spacing: 0.1em; }
.keypad-msg { min-height: 40px; font-size: 15px; display: grid; place-items: center; }
.keypad-msg.good { color: var(--green); font-weight: bold; font-size: 20px; }
.keypad-msg.bad, .keypad-msg.warn { color: #ff8a7a; }
.keypad-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.keypad-grid button { height: 54px; border: none; border-radius: 10px; background: #5a5f65; color: #fff; font: bold 24px monospace;
  cursor: pointer; box-shadow: 0 4px 0 #34383b; }
.keypad-grid button:active { transform: translateY(3px); box-shadow: 0 1px 0 #34383b; }
.keypad-grid button.ok { background: #2f8f4e; box-shadow: 0 4px 0 #1d5a31; }
.keypad-grid button.clear { background: #9a3b30; box-shadow: 0 4px 0 #5e231c; }
.keypad-hint { margin-top: 12px; font-size: 13px; opacity: 0.7; }

/* ---------- caught / fade ---------- */
#fade { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; }
#caught { position: fixed; inset: 0; display: grid; place-content: center; text-align: center; pointer-events: none; }
#caught h2 { margin: 0; font-size: clamp(36px, 7vw, 64px); color: var(--accent); letter-spacing: 0.05em; }
#caught p { font-size: 20px; }

/* ---------- screens ---------- */
.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 16px; text-align: center; background: radial-gradient(ellipse at center, rgba(20,16,10,0.88), rgba(0,0,0,0.97));
  overflow-y: auto; }
/* menu picture made with gpt-image-2.6-flare */
#menu { background: radial-gradient(ellipse at center, rgba(8,8,10,0.55), rgba(0,0,0,0.92)), url('assets/images/menu_bg.jpg') center / cover no-repeat, #000; }
.screen h1 { margin: 0; font-family: Impact, "Arial Black", sans-serif; font-size: clamp(56px, 11vw, 120px); line-height: 0.9;
  letter-spacing: 0.04em; color: #ddd3bd; text-shadow: 0 0 30px rgba(242,192,35,0.25), 4px 4px 0 #000; }
.screen h1 span { color: var(--accent); }
.screen .sub { max-width: 560px; font-size: 18px; line-height: 1.5; opacity: 0.85; }
.controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 10px 24px; max-width: 620px;
  width: 100%; margin: 14px 0; padding: 16px; background: rgba(255,255,255,0.05); border-radius: 12px; text-align: left; font-size: 16px; }
.tip { font-size: 15px; color: var(--accent); }
.screen button { margin-top: 18px; padding: 14px 44px; font: bold 22px "Trebuchet MS", sans-serif; letter-spacing: 0.15em;
  color: #111; background: var(--accent); border: none; border-radius: 10px; cursor: pointer; box-shadow: 0 5px 0 #8a6a0c; }
.screen button:disabled { opacity: 0.5; cursor: wait; }
.screen button:hover:not(:disabled) { filter: brightness(1.1); }
.win-title { color: var(--green) !important; }
#win-stats { font-size: 22px; line-height: 1.7; }

/* ---------- close buttons on keypad / mixer ---------- */
.keypad-box { position: relative; }
.close-x { position: absolute; top: 8px; right: 8px; width: 40px; height: 40px; border: none; border-radius: 50%;
  background: #44494d; color: #fff; font-size: 20px; cursor: pointer; }

/* ---------- paint mixer ---------- */
#mixer { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(0,0,0,0.45); }
.mixer-box { width: min(400px, calc(100vw - 24px)); }
.mixer-slots { display: flex; justify-content: center; gap: 14px; margin-bottom: 10px; }
.mslot { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.mslot span { display: grid; place-items: center; width: 70px; height: 62px; border-radius: 10px; border: 3px solid #44494d;
  color: #fff; font: bold 30px sans-serif; text-shadow: 0 1px 3px #000; }
.mslot.now span { border-color: var(--accent); box-shadow: 0 0 12px rgba(242,192,35,0.5); }
.mslot label { font: bold 13px sans-serif; text-transform: uppercase; letter-spacing: 0.1em; }
.mixer-picks { display: flex; justify-content: center; align-items: center; gap: 10px; font-size: 26px; margin: 4px 0; }
.blob { width: 46px; height: 46px; border-radius: 50%; border: 3px solid rgba(255,255,255,0.3); }
.blob.empty { background: transparent; border-style: dashed; }
.mixer-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mixer-grid button { height: 56px; border: none; border-radius: 10px; color: #fff; font: bold 18px sans-serif; cursor: pointer;
  background: #5a5f65; box-shadow: 0 4px 0 #34383b; text-shadow: 0 1px 2px #000; }
.mixer-grid button.paint { background: var(--c); box-shadow: 0 4px 0 rgba(0,0,0,0.45); }
.mixer-grid button.clear { background: #9a3b30; box-shadow: 0 4px 0 #5e231c; }
.mixer-grid button.mix { grid-column: span 2; background: #2f8f4e; box-shadow: 0 4px 0 #1d5a31; font-size: 22px; }
.mixer-grid button:active { transform: translateY(3px); }

/* ---------- touch controls ---------- */
body.touch #crosshair { width: 8px; height: 8px; margin: -4px 0 0 -4px; }
#touch-ui { position: absolute; inset: 0; }
#touch-zone { position: absolute; inset: 0; pointer-events: auto; touch-action: none; }
#joy-base { position: absolute; width: 130px; height: 130px; margin: -65px 0 0 -65px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,0.35); background: rgba(255,255,255,0.08); display: none; pointer-events: none; }
#joy-base.on { display: block; }
#joy-base.run { border-color: var(--accent); }
#joy-knob { position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; margin: -29px 0 0 -29px; border-radius: 50%;
  background: rgba(255,255,255,0.55); }
.touch-hint { position: absolute; left: 6%; bottom: 18%; font-size: 14px; opacity: 0.45; pointer-events: none; text-align: center; }
.touch-hint.right { left: auto; right: 30%; }
.tbtn { position: absolute; pointer-events: auto; touch-action: none; border: 3px solid rgba(255,255,255,0.4); border-radius: 50%;
  background: rgba(20,22,25,0.6); color: #fff; font: bold 18px sans-serif; -webkit-user-select: none; user-select: none; }
.tbtn.use { right: calc(24px + env(safe-area-inset-right)); bottom: calc(40px + env(safe-area-inset-bottom)); width: 92px; height: 92px; font-size: 20px; }
.tbtn.use.ready { background: rgba(242,192,35,0.85); color: #111; border-color: #fff; box-shadow: 0 0 18px rgba(242,192,35,0.7); }
.tbtn.light { right: calc(132px + env(safe-area-inset-right)); bottom: calc(30px + env(safe-area-inset-bottom)); width: 62px; height: 62px; font-size: 24px; }
.tbtn.pause { left: 50%; top: calc(10px + env(safe-area-inset-top)); width: 46px; height: 46px; margin-left: -23px; font-size: 14px; }
.rotate-hint { color: var(--accent); }

/* ---------- small screens ---------- */
@media (max-width: 760px), (max-height: 500px) {
  #objective { left: 10px; top: 10px; font-size: 13px; padding: 7px 10px; max-width: min(300px, 46vw); }
  #inventory { right: 10px; top: 10px; flex-wrap: wrap; justify-content: flex-end; max-width: 44vw; gap: 5px; }
  #inventory .chip { font-size: 13px; padding: 5px 8px; }
  #prompt { font-size: 15px; padding: 6px 12px; white-space: normal; max-width: 80vw; text-align: center; }
  #toast { font-size: 15px; top: 26%; padding: 9px 14px; }
  #note { right: 50%; transform: translate(50%, -50%); }
  #note-paper { font-size: 16px; padding: 16px 18px; }
  .screen h1 { font-size: clamp(40px, 12vw, 80px); }
  .screen .sub { font-size: 15px; }
  .controls { font-size: 14px; padding: 10px; margin: 8px 0; }
  .screen button { padding: 12px 34px; font-size: 19px; margin-top: 10px; }
  .slot span { width: 54px; height: 60px; font-size: 34px; }
  .keypad-grid button { height: 46px; }
  .keypad-box { padding: 14px; }
}
@media (max-height: 500px) {
  .keypad-box { transform: scale(0.8); }
  .screen { padding: 8px 16px; }
  .screen h1 { font-size: min(15vh, 12vw); }
  .screen .sub { margin: 4px 0; font-size: 13px; line-height: 1.35; }
  .controls { font-size: 12px; padding: 6px 10px; margin: 4px 0; gap: 4px 16px; }
  .tip { font-size: 12px; margin: 4px 0; }
  .screen button { margin-top: 6px; padding: 10px 30px; }
}
@media (orientation: landscape) { .rotate-hint { display: none !important; } }

/* ---------- maze compass ---------- */
#compass { position: absolute; left: 50%; top: 16px; transform: translateX(-50%); display: flex; flex-direction: column;
  align-items: center; gap: 2px; padding: 6px 12px 6px; border-radius: 12px; background: var(--panel); }
#compass .needle { font-size: 30px; line-height: 1; color: #ffd060; text-shadow: 0 0 10px rgba(255,208,96,0.8); }
#compass span { font-size: 12px; letter-spacing: 0.1em; text-transform: uppercase; color: #ffd060; }
body.touch #compass { top: 62px; }
