:root {
  /* the night look, as every Deepwing game (this product's own); the light look is chosen with the switch beside Home */
  --bg: #141a24;
  --bg2: #222c3b;
  --ink: #e8edf5;
  --inkDim: #9aa8bd;
  --line: #34425a;
  --accent: #f98c2e;
  --accentInk: #10151e;
  --sel: #33415a;
  --glow: #ffd166;
  --stageBg: #0b0f16;
  --bubbleBg: #fdfaf2;
  --bubbleInk: #141a24;
  --ringBack: #2b3647;
  --ringFill: #5fd08a;
  --ringLow: #ffb44d;
  --shade: rgba(16, 22, 32, 0.92);
  --toastBg: #fdfaf2;
  --toastInk: #141a24;
  --danger: #ff8a80;
}
:root[data-theme="light"] {
  --bg: #eef2f7;
  --bg2: #dbe3ee;
  --ink: #10151e;
  --inkDim: #45526a;
  --line: #a9b6c9;
  --accent: #c2560a;
  --accentInk: #ffffff;
  --sel: #c9d6e8;
  --glow: #d98a00;
  --stageBg: #1b2431;
  --bubbleBg: #ffffff;
  --bubbleInk: #10151e;
  --ringBack: #c6d0dd;
  --ringFill: #23955a;
  --ringLow: #c46a00;
  --shade: rgba(238, 242, 247, 0.92);
  --toastBg: #10151e;
  --toastInk: #ffffff;
  --danger: #b42318;
}

* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg2) 100%);
  color: var(--ink); user-select: none; -webkit-user-select: none; overflow: hidden;
}
#app { height: 100%; display: flex; flex-direction: column; max-width: min(100%, 900px); margin: 0 auto; }

#hdr { display: flex; align-items: center; gap: 8px; padding: 8px 12px; padding-top: max(8px, env(safe-area-inset-top)); }
#hdr .pill { background: var(--bg2); border: 2px solid var(--line); border-radius: 999px; padding: 6px 11px; font-weight: 800; font-size: 15px; min-width: 44px; min-height: 44px; display: flex; align-items: center; cursor: pointer; justify-content: center; color: inherit; font-family: inherit; }
#hdrHome { border: none; background: var(--accent); color: var(--accentInk); font-size: 18px; }
#hdrStatus { flex: 1; min-width: 0; text-align: center; font-weight: 800; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--inkDim); }

.scr { flex: 1; display: none; flex-direction: column; overflow-y: auto; padding: 6px 14px 18px; gap: 10px; min-height: 0; }
.scr.on { display: flex; }
.scrTitle { color: var(--ink); font-size: 22px; }

#scr-menu { align-items: center; text-align: center; justify-content: center; }
#scr-menu h1 { font-size: clamp(32px, 9vw, 46px); color: var(--ink); }
#scr-menu .sub { color: var(--inkDim); font-weight: 600; }
.menuGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: 100%; }
button.big { width: 100%; border-radius: 16px; min-height: 52px; font-size: 18px; font-weight: 800; background: var(--bg2); color: var(--ink); border: 3px solid var(--line); cursor: pointer; font-family: inherit; padding: 6px 10px; }
button.big:active { transform: translateY(2px); }
button.big.primary { background: var(--accent); border-color: var(--accent); color: var(--accentInk); }
button.big.danger { border-color: var(--danger); color: var(--danger); min-height: 52px; }
button.big:disabled { opacity: 0.5; cursor: default; }
#statsLine { color: var(--inkDim); font-weight: 700; }
.seg { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
.seg button { flex: 1; min-height: 44px; min-width: 64px; border-radius: 12px; border: 3px solid var(--line); background: var(--bg); color: var(--ink); font: 800 15px inherit; font-family: inherit; cursor: pointer; }
.seg button.sel { border-color: var(--accent); background: var(--sel); }

/* choosing a pet */
.pickRow { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 8px; }
.pick { min-height: 88px; border-radius: 16px; border: 3px solid var(--line); background: var(--bg); color: var(--ink); font-family: inherit; font-weight: 800; font-size: 15px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; cursor: pointer; padding: 6px; }
.pick.sel { border-color: var(--accent); background: var(--sel); }
.pick .pe { font-size: 40px; line-height: 1; }
.pick .pl { font-size: 14px; line-height: 1.2; }
.pick.coat { min-height: 84px; }
.pick .sw { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--line); }
.nameRow { display: flex; align-items: center; gap: 10px; font-size: 18px; }
#nameIn { flex: 1; min-width: 0; min-height: 48px; border-radius: 12px; border: 3px solid var(--line); background: var(--bg); color: var(--ink); font: 700 20px inherit; font-family: inherit; padding: 4px 12px; user-select: text; -webkit-user-select: text; }

/* playing */
#scr-play { padding: 0 10px 10px; gap: 8px; }
#needs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.need { position: relative; display: flex; align-items: center; justify-content: center; height: 46px; }
.need .ring { position: absolute; width: 42px; height: 42px; border-radius: 50%; background: conic-gradient(var(--ringFill) var(--v, 100%), var(--ringBack) 0); }
.need.low .ring { background: conic-gradient(var(--ringLow) var(--v, 100%), var(--ringBack) 0); }
.need .ring::after { content: ''; position: absolute; inset: 5px; border-radius: 50%; background: var(--bg); }
.need .ni { position: relative; font-size: 18px; }
#stageWrap { position: relative; flex: 1; min-height: 220px; border-radius: 18px; overflow: hidden; background: var(--stageBg); }
#stage { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
#bubble { position: absolute; transform: translateX(-50%); background: var(--bubbleBg); color: var(--bubbleInk); border-radius: 18px; padding: 6px 12px; font-size: 22px; font-weight: 800; white-space: nowrap; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18); pointer-events: none; }
#bubble::after { content: ''; position: absolute; left: 50%; bottom: -9px; width: 12px; height: 12px; margin-left: -6px; border-radius: 50%; background: var(--bubbleBg); }
#floaters { position: absolute; inset: 0; pointer-events: none; }
.fl { position: absolute; font-size: 28px; transform: translate(-50%, 0); animation: up 1.5s ease-out forwards; opacity: 0; }
@keyframes up { 0% { opacity: 0; transform: translate(-50%, 0) scale(0.6); } 15% { opacity: 1; transform: translate(-50%, -12px) scale(1.1); } 100% { opacity: 0; transform: translate(-50%, -90px) scale(1); } }
#hint { position: absolute; left: 0; right: 0; bottom: 8px; text-align: center; font-weight: 800; font-size: 15px; color: var(--ink); text-shadow: 0 0 6px var(--bg), 0 0 2px var(--bg); pointer-events: none; padding: 0 10px; }
#glFail { position: absolute; inset: 12px; display: flex; align-items: center; justify-content: center; text-align: center; background: var(--shade); color: var(--ink); border-radius: 14px; padding: 16px; font-weight: 700; }
#glFail[hidden] { display: none; }
#fpsNow { position: absolute; top: 6px; left: 8px; font: 700 12px ui-monospace, monospace; color: var(--ink); background: var(--shade); border-radius: 6px; padding: 2px 6px; pointer-events: none; }
#tray { display: flex; flex-wrap: nowrap; gap: 6px; height: 50px; overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.tb { flex: 1 0 auto; min-height: 46px; min-width: 96px; border-radius: 14px; border: 3px solid var(--line); background: var(--bg); color: var(--ink); font-family: inherit; font-weight: 800; font-size: 15px; cursor: pointer; padding: 4px 10px; }
.tb.sel { border-color: var(--accent); background: var(--sel); }
.tb.wide { flex: 1 0 40%; }
#tabs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; padding-bottom: env(safe-area-inset-bottom); }
.tab { min-height: 60px; min-width: 0; border-radius: 16px; border: 3px solid var(--line); background: var(--bg2); color: var(--ink); font-family: inherit; font-size: 24px; cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 2px; }
.tab span { font-size: 12px; font-weight: 800; }
.tab.sel { border-color: var(--accent); background: var(--sel); }
.tab.glow { border-color: var(--glow); box-shadow: 0 0 0 3px var(--glow); }

/* help and settings */
.card { background: var(--bg2); border: 2px solid var(--line); border-radius: 16px; padding: 12px 14px; line-height: 1.45; display: flex; flex-direction: column; gap: 8px; }
.card h2 { font-size: 19px; }
.setRow { display: flex; flex-direction: column; gap: 6px; }
.setNote { color: var(--inkDim); font-weight: 600; font-size: 14px; }

#toast { position: fixed; left: 50%; bottom: calc(18px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--toastBg); color: var(--toastInk); padding: 10px 16px; border-radius: 14px; font-weight: 800; opacity: 0; transition: opacity 0.2s; pointer-events: none; max-width: 90%; text-align: center; z-index: 10; }
#toast.on { opacity: 1; }
#footer { display: flex; justify-content: center; padding: 2px 0 calc(2px + env(safe-area-inset-bottom)); }
@media (prefers-reduced-motion: reduce) { .fl { animation-duration: 0.01s; } button.big:active { transform: none; } }
