/* PAC-MAN 2027* — styles */
:root {
  --bg: #07061a; --panel: rgba(18, 16, 44, 0.92); --panel2: rgba(255, 255, 255, 0.06); --line: rgba(255, 255, 255, 0.1);
  --ink: #f4f3ff; --muted: #a8a5cf; --yellow: #ffe14d; --cyan: #4ef2ff; --pink: #ff4fd8; --red: #ff3b5c; --green: #5dff9e; --violet: #9b7bff;
  --display: 'Orbitron', 'Rubik', system-ui, sans-serif;
  --text: 'Rubik', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; position: fixed; inset: 0; background: var(--bg); }
body { color: var(--ink); font-family: var(--text); -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; user-select: none; -webkit-user-select: none; touch-action: none; }
button, input, select { font-family: inherit; color: inherit; }
button { cursor: pointer; }
input { user-select: text; -webkit-user-select: text; }
:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }
.hidden { display: none !important; }

#app { position: fixed; inset: 0; overflow: hidden; }

/* ---------- buttons ---------- */
.btn {
  border: 0; border-radius: 14px; padding: 11px 18px; font: 700 15px var(--text); letter-spacing: 0.02em;
  background: var(--panel2); color: var(--ink); box-shadow: inset 0 0 0 1px var(--line); transition: transform 0.12s, box-shadow 0.15s, background 0.15s;
}
.btn:hover { transform: translateY(-1px); background: rgba(255, 255, 255, 0.1); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: default; transform: none; }
.btn.play {
  font: 900 clamp(17px, 2.6vh, 22px) var(--display); letter-spacing: 0.12em; color: #1a1300; padding: clamp(10px, 1.8vh, 16px) clamp(34px, 6vw, 64px);
  background: linear-gradient(180deg, #fff27a, #ffd21a); border-radius: 999px; box-shadow: 0 0 0 2px rgba(255, 225, 77, 0.35), 0 0 28px rgba(255, 210, 26, 0.45), 0 6px 0 #b88c00;
}
.btn.play:hover { background: linear-gradient(180deg, #fff59a, #ffdb3a); }
.btn.cyan { background: linear-gradient(180deg, #7ff7ff, #23c8e0); color: #002229; box-shadow: 0 0 22px rgba(78, 242, 255, 0.35); }
.btn.ghost { background: transparent; }
.btn.small { padding: 7px 12px; font-size: 13px; border-radius: 10px; }
.icon-btn {
  position: relative; width: 42px; height: 42px; border-radius: 12px; border: 0; background: var(--panel2); box-shadow: inset 0 0 0 1px var(--line);
  font-size: 18px; display: grid; place-items: center; transition: transform 0.12s, background 0.15s; flex: none;
}
.icon-btn:hover { background: rgba(255, 255, 255, 0.12); transform: translateY(-1px); }
.icon-btn.small { width: 34px; height: 34px; font-size: 13px; }
.icon-btn .dot { position: absolute; top: 6px; right: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--red); box-shadow: 0 0 8px var(--red); }

/* ---------- stage ---------- */
#stage { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: max(6px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(6px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
#board-wrap { position: relative; flex: 1 1 auto; min-height: 0; width: 100%; display: grid; place-items: center; }
#cv { display: block; border-radius: 10px; }
.hud { width: 100%; max-width: var(--board-w, 560px); display: flex; align-items: center; gap: 10px; flex: none; }
#hud-top { height: 46px; }
#hud-bot { height: 40px; justify-content: space-between; }
.hbox { flex: 1; min-width: 0; line-height: 1.05; }
.hbox small { display: block; font: 700 10px var(--display); letter-spacing: 0.14em; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbox b { display: block; font: 900 clamp(15px, 2.6vh, 21px) var(--display); color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hbox.mid { text-align: center; }
.hbox.mid b { color: var(--yellow); }
.hbox.right { text-align: right; }
.lives { display: flex; gap: 4px; min-width: 0; }
.lives img { width: 22px; height: 22px; }
.fruits { display: flex; gap: 2px; flex-direction: row-reverse; }
.fruits img { width: 24px; height: 24px; }
.powers { display: flex; gap: 6px; flex: 1; justify-content: center; min-width: 0; overflow: hidden; }
.pchip { display: flex; align-items: center; gap: 4px; padding: 2px 8px 2px 2px; border-radius: 99px; background: var(--panel2); font: 700 12px var(--display); white-space: nowrap; }
.pchip img { width: 22px; height: 22px; }
.rchip { display: flex; align-items: center; gap: 5px; padding: 3px 8px; border-radius: 99px; background: var(--panel2); font: 700 11px var(--display); white-space: nowrap; }
.rchip i { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.rchip.me { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.5); }
.combo { display: flex; align-items: center; gap: 6px; font: 900 14px var(--display); color: var(--yellow); }
.combo i { display: block; width: 54px; height: 6px; border-radius: 9px; background: var(--panel2); overflow: hidden; }
.combo em { display: block; height: 100%; background: linear-gradient(90deg, var(--yellow), var(--pink)); border-radius: 9px; }

.banner {
  position: absolute; left: 50%; top: 42%; transform: translate(-50%, -50%); text-align: center; pointer-events: none; z-index: 5;
  padding: 12px 22px; border-radius: 16px; background: rgba(7, 6, 26, 0.82); box-shadow: 0 0 0 1px var(--line), 0 0 40px rgba(155, 123, 255, 0.35);
  animation: pop 0.35s cubic-bezier(0.3, 1.5, 0.5, 1); max-width: 92%;
}
.banner b { display: block; font: 900 clamp(18px, 3.4vh, 30px) var(--display); letter-spacing: 0.1em; color: var(--cyan); text-shadow: 0 0 18px rgba(78, 242, 255, 0.7); }
.banner span { display: block; margin-top: 4px; font: 500 clamp(12px, 1.8vh, 15px) var(--text); color: var(--ink); }
@keyframes pop { from { opacity: 0; transform: translate(-50%, -50%) scale(0.8); } }

.dpad { position: relative; width: 168px; height: 168px; flex: none; margin-top: 6px; touch-action: none; }
.dpad button { position: absolute; width: 58px; height: 58px; border-radius: 16px; border: 0; background: rgba(255, 255, 255, 0.08); box-shadow: inset 0 0 0 1px var(--line); color: var(--muted); font-size: 20px; }
.dpad button.on { background: rgba(255, 225, 77, 0.35); color: #fff; }
.dpad .up { left: 55px; top: 0; } .dpad .down { left: 55px; bottom: 0; } .dpad .left { left: 0; top: 55px; } .dpad .right { right: 0; top: 55px; }
.dpad.side { position: absolute; left: max(10px, env(safe-area-inset-left)); bottom: max(10px, env(safe-area-inset-bottom)); margin: 0; opacity: 0.85; }

/* ---------- menu ---------- */
.screen { position: absolute; inset: 0; z-index: 10; display: flex; flex-direction: column; overflow: hidden;
  background: radial-gradient(70% 55% at 50% 0%, rgba(155, 123, 255, 0.28), transparent 70%), radial-gradient(60% 50% at 50% 100%, rgba(78, 242, 255, 0.14), transparent 70%), rgba(7, 6, 26, 0.78);
  padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left)); }
.topbar { display: flex; align-items: center; gap: 8px; flex: none; }
.topbar .grow { flex: 1; }
.profile { display: flex; align-items: center; gap: 10px; padding: 5px 14px 5px 5px; border: 0; border-radius: 16px; background: var(--panel2); box-shadow: inset 0 0 0 1px var(--line); text-align: left; min-width: 0; }
.profile canvas { width: 36px; height: 36px; border-radius: 10px; background: rgba(0, 0, 0, 0.35); flex: none; }
.pinfo { min-width: 0; }
.pinfo b { display: block; font: 700 13px var(--display); letter-spacing: 0.06em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.pinfo small { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; }
.xpbar { display: block; width: 110px; height: 4px; border-radius: 9px; background: rgba(255, 255, 255, 0.1); overflow: hidden; margin-top: 3px; }
.xpbar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--cyan), var(--pink)); border-radius: 9px; transition: width 0.6s; }
.coins { font: 900 14px var(--display); color: var(--yellow); padding: 8px 12px; border-radius: 99px; background: rgba(255, 225, 77, 0.1); box-shadow: inset 0 0 0 1px rgba(255, 225, 77, 0.25); white-space: nowrap; }

.menu-main { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: clamp(6px, 1.7vh, 16px); text-align: center; }
.logo { margin: 0; line-height: 0.92; font-family: var(--display); font-weight: 900; letter-spacing: 0.04em; }
.logo .l1 { display: block; font-size: clamp(34px, min(10.5vw, 10vh), 100px); color: var(--yellow); text-shadow: 0 0 22px rgba(255, 210, 26, 0.65), 0 4px 0 #b88c00; }
.logo .l2 { display: inline-block; font-size: clamp(26px, min(8vw, 7.4vh), 74px); background: linear-gradient(90deg, var(--cyan), var(--violet) 50%, var(--pink)); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 0 14px rgba(155, 123, 255, 0.6)); letter-spacing: 0.32em; margin-right: -0.32em; }
.logo sup { font-size: 0.45em; color: var(--pink); -webkit-text-fill-color: var(--pink); letter-spacing: 0; vertical-align: top; }
.tagline { margin: 0; color: var(--muted); font-size: clamp(13px, 1.9vh, 16px); }
.modes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; width: min(880px, 100%); }
.mode {
  border: 0; border-radius: 16px; padding: clamp(9px, 1.6vh, 14px) 10px; text-align: left; background: var(--panel); box-shadow: inset 0 0 0 1px var(--line);
  transition: transform 0.12s, box-shadow 0.15s; display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; align-items: center; min-width: 0;
}
.mode:hover { transform: translateY(-2px); }
.mode .ic { grid-row: span 2; font-size: clamp(22px, 3.4vh, 30px); }
.mode b { font: 900 clamp(13px, 2vh, 16px) var(--display); letter-spacing: 0.06em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mode small { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mode.sel { box-shadow: inset 0 0 0 2px var(--yellow), 0 0 26px rgba(255, 225, 77, 0.25); }
.mode .badge { grid-column: 1 / -1; justify-self: start; font: 700 10px var(--display); letter-spacing: 0.08em; padding: 2px 7px; border-radius: 99px; background: rgba(93, 255, 158, 0.15); color: var(--green); margin-top: 3px; }
.mode-desc { margin: 0; color: var(--ink); font-size: clamp(12px, 1.8vh, 14px); max-width: 640px; opacity: 0.85; min-height: 1.2em; }
.opts { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px 16px; min-height: 36px; }
.opt { display: flex; align-items: center; gap: 8px; font: 700 11px var(--display); letter-spacing: 0.08em; color: var(--muted); }
.seg { display: inline-flex; padding: 3px; gap: 3px; border-radius: 12px; background: var(--panel); box-shadow: inset 0 0 0 1px var(--line); }
.seg button { border: 0; background: transparent; padding: 6px 11px; border-radius: 9px; font: 700 13px var(--text); color: var(--muted); }
.seg button.sel { background: rgba(255, 225, 77, 0.16); color: var(--yellow); box-shadow: inset 0 0 0 1px rgba(255, 225, 77, 0.4); }
.seg button:disabled { opacity: 0.35; cursor: default; }
.hint { margin: 0; font-size: 12px; color: var(--muted); }
.foot { flex: none; text-align: center; font-size: 10.5px; color: rgba(168, 165, 207, 0.7); margin-top: 4px; }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; z-index: 30; display: flex; padding: 14px; background: rgba(4, 3, 15, 0.72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); animation: fade 0.18s; }
#pause { z-index: 25; }
@keyframes fade { from { opacity: 0; } }
.sheet { position: relative; margin: auto; width: min(620px, 100%); max-height: 100%; overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y;
  background: linear-gradient(180deg, rgba(30, 26, 70, 0.98), rgba(14, 12, 36, 0.98)); border-radius: 22px; padding: 20px; box-shadow: 0 0 0 1px var(--line), 0 30px 80px rgba(0, 0, 0, 0.5); animation: rise 0.25s ease-out; }
.sheet.small { width: min(340px, 100%); text-align: center; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }
.sheet h2 { margin: 0 0 12px; font: 900 22px var(--display); letter-spacing: 0.08em; }
.sheet h3 { margin: 16px 0 8px; font: 700 12px var(--display); letter-spacing: 0.14em; color: var(--muted); text-transform: uppercase; }
.sheet p, .sheet li { color: var(--muted); line-height: 1.5; font-size: 14px; }
.sheet .close { position: absolute; top: 12px; right: 12px; width: 36px; height: 36px; border-radius: 10px; border: 0; background: var(--panel2); font-size: 15px; z-index: 2; }
.col-btns { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.row-btns { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 16px; }

.big-score { font: 900 clamp(38px, 7vh, 56px) var(--display); color: var(--yellow); text-shadow: 0 0 24px rgba(255, 210, 26, 0.55); text-align: center; line-height: 1.1; }
.res-title { text-align: center; font: 900 clamp(20px, 3.6vh, 28px) var(--display); letter-spacing: 0.12em; margin: 0; }
.res-sub { text-align: center; color: var(--muted); margin: 4px 0 0; font-size: 14px; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 14px 0; }
.kpi { background: var(--panel2); border-radius: 12px; padding: 9px 4px; text-align: center; }
.kpi b { display: block; font: 900 18px var(--display); font-variant-numeric: tabular-nums; }
.kpi span { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.rewards { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }
.rewards span { padding: 6px 12px; border-radius: 99px; background: var(--panel2); font: 700 13px var(--text); }
.rewards span.gold { background: rgba(255, 225, 77, 0.14); color: var(--yellow); }
.rewards span.green { background: rgba(93, 255, 158, 0.12); color: var(--green); }
.lvl { display: flex; align-items: center; gap: 10px; background: var(--panel2); border-radius: 12px; padding: 9px 12px; margin-top: 10px; font: 700 13px var(--display); }
.lvl .xpbar { flex: 1; width: auto; height: 7px; margin: 0; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table td, .table th { padding: 7px 6px; text-align: left; border-bottom: 1px solid var(--line); }
.table th { font: 700 10px var(--display); letter-spacing: 0.1em; color: var(--muted); }
.table td.num { text-align: right; font: 700 14px var(--display); font-variant-numeric: tabular-nums; }
.table tr.me td { color: var(--yellow); }
.table tr.cpu td { color: var(--muted); }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 50%; vertical-align: -1px; margin-right: 6px; }

.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--panel2); margin: 10px 0; }
.tabs button { flex: 1; border: 0; padding: 8px 4px; border-radius: 9px; background: transparent; font: 700 13px var(--text); color: var(--muted); }
.tabs button.sel { background: rgba(255, 225, 77, 0.16); color: var(--yellow); }
.garage-top { display: flex; gap: 14px; align-items: center; }
.garage-top canvas { width: 120px; height: 120px; border-radius: 18px; background: radial-gradient(circle, rgba(155, 123, 255, 0.25), rgba(0, 0, 0, 0.3)); flex: none; }
.items { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; }
.item { position: relative; border: 0; border-radius: 14px; padding: 10px 8px; background: var(--panel2); box-shadow: inset 0 0 0 1px var(--line); text-align: center; font: 700 13px var(--text); }
.item canvas { width: 54px; height: 54px; display: block; margin: 0 auto 4px; }
.item small { display: block; font-weight: 500; font-size: 11px; color: var(--muted); margin-top: 3px; }
.item small.price { color: var(--yellow); font-weight: 700; }
.item.eq { box-shadow: inset 0 0 0 2px var(--yellow); }
.item.eq::after { content: '✓'; position: absolute; top: 6px; right: 9px; color: var(--yellow); }
.item.locked { opacity: 0.6; }
.item.shake { animation: shake 0.3s; }
@keyframes shake { 25% { transform: translateX(-5px); } 75% { transform: translateX(5px); } }

.mission { display: flex; align-items: center; gap: 12px; background: var(--panel2); border-radius: 14px; padding: 12px; margin-bottom: 8px; }
.mission .mtxt { flex: 1; min-width: 0; }
.mission b { display: block; font-size: 14px; }
.mission .bar { height: 6px; border-radius: 9px; background: rgba(255, 255, 255, 0.08); margin-top: 6px; overflow: hidden; }
.mission .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--green), var(--cyan)); }
.mission .rw { font: 900 13px var(--display); color: var(--yellow); white-space: nowrap; }
.mission.done { box-shadow: inset 0 0 0 1px rgba(93, 255, 158, 0.5); }
.ach-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.ach { display: flex; gap: 10px; align-items: center; background: var(--panel2); border-radius: 12px; padding: 9px; opacity: 0.45; filter: grayscale(1); }
.ach.got { opacity: 1; filter: none; box-shadow: inset 0 0 0 1px rgba(255, 225, 77, 0.3); }
.ach .i { font-size: 22px; }
.ach b { display: block; font-size: 13px; }
.ach small { display: block; font-size: 11px; color: var(--muted); line-height: 1.3; }
.set { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); font-weight: 700; font-size: 14px; }
.set:last-child { border-bottom: 0; }
.switch { width: 48px; height: 28px; border-radius: 99px; border: 0; background: rgba(255, 255, 255, 0.14); position: relative; flex: none; transition: background 0.2s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: transform 0.2s; }
.switch.on { background: var(--green); }
.switch.on::after { transform: translateX(20px); }
.text-in { width: 100%; padding: 10px 12px; border-radius: 12px; border: 0; background: rgba(0, 0, 0, 0.3); box-shadow: inset 0 0 0 1px var(--line); font: 700 15px var(--display); letter-spacing: 0.06em; text-transform: uppercase; outline: 0; }
.text-in:focus { box-shadow: inset 0 0 0 2px var(--cyan); }
input[type=range] { accent-color: var(--yellow); width: 150px; }
.pu-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.pu { display: flex; align-items: center; gap: 8px; background: var(--panel2); border-radius: 12px; padding: 8px; }
.pu img { width: 30px; height: 30px; }
.pu b { display: block; font-size: 13px; color: var(--ink); }
.pu small { display: block; font-size: 11px; color: var(--muted); }
.gh { display: flex; gap: 10px; align-items: center; margin: 6px 0; }
.gh i { width: 14px; height: 14px; border-radius: 50%; flex: none; }

#toasts { position: fixed; top: max(12px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); z-index: 60; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; width: min(420px, 92%); }
.toast { padding: 10px 16px; border-radius: 14px; background: rgba(18, 16, 44, 0.96); box-shadow: 0 0 0 1px var(--line), 0 10px 30px rgba(0, 0, 0, 0.4); font: 700 14px var(--text); animation: rise 0.25s; text-align: center; }
.toast.gold { box-shadow: 0 0 0 1px rgba(255, 225, 77, 0.5), 0 0 24px rgba(255, 225, 77, 0.25); }

/* ---------- small and short screens ---------- */
@media (max-width: 700px) {
  .modes { grid-template-columns: repeat(2, 1fr); }
  .topbar { gap: 6px; }
  .icon-btn { width: 36px; height: 36px; font-size: 15px; border-radius: 10px; }
  .pinfo b { max-width: 90px; }
  .xpbar { width: 70px; }
  .coins { padding: 6px 9px; font-size: 12px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .ach-grid, .pu-list { grid-template-columns: 1fr; }
}
@media (max-width: 420px) {
  .profile .pinfo small { display: none; }
  #fs-btn { display: none; }
}
@media (max-height: 600px) {
  .tagline, .hint { display: none; }
  .mode small { display: none; }
  .mode .ic { grid-row: auto; }
  .foot { font-size: 9px; }
}
@media (max-height: 430px) {
  .menu-main { gap: 5px; }
  .modes { grid-template-columns: repeat(4, 1fr); }
  .mode { padding: 6px 8px; }
  .mode-desc { display: none; }
  .foot { display: none; }
  #hud-top { height: 34px; }
  #hud-bot { height: 30px; }
}
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; } }
