:root {
  --water-top: #24306b; --water-mid: #34418f; --water-low: #1c2450;
  --led: #9fe0ff; --sand: #f3e9d8; --amphora: #ff8c42;
  --ink: #eef2ff; --ink-dim: #aab4e0;
  --card: #232b57; --card-2: #1b2248;
  --good: #5ad17d; --bad: #ff6b6b; --warn: #ffce54;
  --candy1: #ffb3d1; --candy2: #ffe08a; --candy3: #b8f2c9; --candy4: #c4b5ff;
  --radius: 16px;
  font-family: "Trebuchet MS", "Segoe UI", ui-rounded, system-ui, sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { background: #131938; color: var(--ink); min-height: 100vh; touch-action: manipulation; }
button { font-family: inherit; cursor: pointer; border: none; color: inherit; background: none; }
button:focus-visible { outline: 3px solid var(--led); outline-offset: 2px; }
#app { max-width: 620px; margin: 0 auto; padding-bottom: 96px; }

/* header */
header { display: flex; align-items: center; gap: 8px; padding: 10px 12px 4px; flex-wrap: wrap; }
#title { font-size: 1.25rem; letter-spacing: .5px; font-weight: 800; }
#subtitle { width: 100%; color: var(--ink-dim); font-size: .78rem; }
.hud { margin-left: auto; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.hudChip { background: var(--card); border-radius: 999px; padding: 5px 11px; font-size: .84rem; font-weight: 700; white-space: nowrap; }
.flags { display: flex; gap: 4px; }
.flag { line-height: 0; padding: 4px; border-radius: 8px; opacity: .45; transition: .2s; }
.flag svg { width: 26px; height: 17px; border-radius: 3px; display: block; }
.flag.active { opacity: 1; background: rgba(159,224,255,.18); box-shadow: 0 0 0 2px var(--led); }
.iconBtn { font-size: 1.1rem; padding: 5px 8px; border-radius: 10px; background: var(--card); }
.coinChip { display: inline-flex; align-items: center; gap: 5px; }
.coinImg { width: 15px; height: 15px; image-rendering: pixelated; vertical-align: -2px; }

/* tank */
#tankWrap { position: relative; margin: 8px 12px 0; border-radius: 14px; overflow: hidden;
  box-shadow: 0 0 0 5px #0d1230, 0 0 34px rgba(159,224,255,.32); }
#tank { display: block; width: 100%; }
#saveChip { position: fixed; top: 10px; right: 10px; z-index: 60; background: var(--good); color: #0c2417; font-weight: 700; font-size: .72rem; padding: 4px 10px; border-radius: 999px; opacity: 0; transition: opacity .3s; pointer-events: none; }
#saveChip.show { opacity: 1; }

/* kiki speech bubble */
#kikiBar { display: flex; gap: 10px; align-items: flex-start; margin: 8px 12px 0; background: var(--card);
  border-radius: 14px; padding: 9px 12px; position: relative; }
#kikiBar img { width: 44px; height: 44px; border-radius: 10px; image-rendering: pixelated; flex: 0 0 44px; }
#kikiText { font-size: .84rem; line-height: 1.45; }
#kikiBar.tappable { box-shadow: 0 0 0 2px var(--led); cursor: pointer; }
#kikiBar.tappable::after { content: "👆"; position: absolute; right: 10px; bottom: 6px; animation: pulse 1.2s infinite; }
#kikiBar.hidden { display: none; }
@keyframes pulse { 50% { transform: translateY(-3px); opacity: .6; } }

/* task board */
#taskboard { display: flex; gap: 6px; margin: 8px 12px 0; flex-wrap: wrap; align-items: center; }
#taskboard .tbTitle { font-size: .74rem; color: var(--ink-dim); font-weight: 700; }
.taskChip { background: var(--card-2); border: 1.5px dashed rgba(255,206,84,.7); color: var(--warn);
  font-size: .76rem; font-weight: 700; padding: 5px 10px; border-radius: 999px; }
.taskChip.done { border-style: solid; border-color: var(--good); color: var(--good); text-decoration: line-through; opacity: .8; }
.taskChip.fast { border-color: var(--candy3); color: var(--candy3); }

/* tabs */
nav { display: flex; gap: 4px; padding: 10px 12px 0; overflow-x: auto; scrollbar-width: none; }
.tab { flex: 1; white-space: nowrap; background: var(--card-2); color: var(--ink-dim); padding: 9px 10px; border-radius: 12px 12px 0 0; font-size: .8rem; font-weight: 700; }
.tab.active { background: var(--card); color: var(--ink); box-shadow: inset 0 3px 0 var(--led); }
.tab.hidden { display: none; }
.tab.attention { animation: glowTab 1.2s infinite; }
@keyframes glowTab { 50% { box-shadow: inset 0 3px 0 var(--warn), 0 0 12px rgba(255,206,84,.5); } }
.panel { display: none; background: var(--card); margin: 0 12px; border-radius: 0 0 var(--radius) var(--radius); padding: 13px; }
.panel.show { display: block; }

/* fish list */
.fishCard { display: flex; gap: 10px; align-items: center; background: var(--card-2); border-radius: 12px; padding: 8px 10px; margin-bottom: 8px; }
.deadCard { opacity: .45; filter: grayscale(1); }
.fishIcon { flex: 0 0 52px; text-align: center; }
.fishIcon img { max-width: 52px; max-height: 40px; image-rendering: pixelated; }
.fishInfo { flex: 1; min-width: 0; }
.fishName { font-weight: 700; font-size: .88rem; margin-bottom: 3px; }
.tagSick { color: var(--warn); font-size: .72rem; } .tagDead { color: var(--bad); font-size: .72rem; }
.barRow { display: flex; align-items: center; gap: 6px; font-size: .66rem; color: var(--ink-dim); margin-top: 2px; }
.barRow span { width: 70px; }
.bar { flex: 1; height: 6px; background: #12173a; border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; transition: width .4s; }
.mini { background: var(--warn); color: #3a2b00; font-weight: 700; padding: 6px 10px; border-radius: 10px; font-size: .74rem; }
#flockNote { font-size: .78rem; color: var(--ink-dim); margin: 2px 2px 8px; }

/* care */
.careGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.careCard { background: var(--card-2); border-radius: 12px; padding: 10px; position: relative; }
.careCard.suggested { box-shadow: inset 0 0 0 2px var(--warn); }
.careCard.suggested::before { content: "★"; position: absolute; top: 6px; right: 8px; color: var(--warn); }
.careCard.locked { opacity: .35; pointer-events: none; }
.careName { font-weight: 700; font-size: .82rem; margin-bottom: 2px; }
.careSub { font-size: .68rem; color: var(--ink-dim); min-height: 1.1em; }
.careBtns { display: flex; gap: 6px; margin-top: 8px; }
.playBtn { flex: 1; background: linear-gradient(135deg, #3fa7ff, #2bd4a4); color: #04222c; font-weight: 800; padding: 9px 6px; border-radius: 10px; font-size: .8rem; }
.quickBtn { background: #3b478f; padding: 9px 8px; border-radius: 10px; font-size: .64rem; font-weight: 800; letter-spacing: .5px; color: var(--ink-dim); }
.careIcon { width: 20px; height: 20px; image-rendering: pixelated; vertical-align: -4px; }
.shopIcon { width: 34px; max-height: 34px; image-rendering: pixelated; }
.careWide { grid-column: 1 / -1; }
input[type=range] { width: 100%; accent-color: var(--led); }
#waterVals { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.chip { padding: 4px 10px; border-radius: 99px; font-size: .72rem; font-weight: 700; }
.chip.good { background: rgba(90,209,125,.2); color: var(--good); }
.chip.bad { background: rgba(255,107,107,.22); color: var(--bad); }
.chip.warn { background: rgba(255,206,84,.2); color: var(--warn); }
.chipMuted { padding: 4px 10px; border-radius: 99px; font-size: .72rem; background: #12173a; color: var(--ink-dim); }

#nextDayBtn { position: fixed; bottom: 14px; left: 50%; transform: translateX(-50%); z-index: 50;
  background: linear-gradient(135deg, #ffb84d, var(--amphora)); color: #3a1c00; font-size: .98rem; font-weight: 800;
  padding: 13px 32px; border-radius: 999px; box-shadow: 0 6px 22px rgba(255,140,66,.45); }
#nextDayBtn:active { transform: translateX(-50%) scale(.96); }
#nextDayBtn.attention { animation: glowNext 1.2s infinite; }
@keyframes glowNext { 50% { box-shadow: 0 6px 30px rgba(255,206,84,.9); } }
#rescueBtn { position: fixed; bottom: 68px; left: 50%; transform: translateX(-50%); z-index: 50;
  background: var(--bad); color: #fff; font-weight: 800; padding: 11px 24px; border-radius: 999px;
  box-shadow: 0 4px 18px rgba(255,80,80,.6); animation: glowNext 0.8s infinite; }

/* shop */
#ratnaCard { display: flex; gap: 10px; background: var(--card-2); border-radius: 12px; padding: 10px; margin-bottom: 10px; align-items: flex-start; }
#ratnaCard img { width: 52px; height: 52px; border-radius: 10px; image-rendering: pixelated; flex: 0 0 52px; }
#ratnaText { font-size: .8rem; line-height: 1.4; }
#ratnaQuiz { margin-top: 8px; }
.quizQ { font-size: .9rem; font-weight: 700; margin: 6px 0 8px; }
.quizA { display: block; width: 100%; text-align: left; background: #2a3468; padding: 11px; border-radius: 10px; margin-bottom: 7px; font-size: .82rem; transition: .2s; }
.quizA.right { background: rgba(90,209,125,.28); box-shadow: inset 0 0 0 2px var(--good); }
.quizA.wrong { background: rgba(255,107,107,.24); box-shadow: inset 0 0 0 2px var(--bad); }
.askBtn { background: linear-gradient(135deg, #ffd76e, #ffb84d); color: #4a2c00; font-weight: 800; padding: 8px 14px; border-radius: 10px; font-size: .8rem; margin-top: 6px; }
.shopCard { display: flex; gap: 10px; align-items: center; background: var(--card-2); border-radius: 12px; padding: 10px; margin-bottom: 8px; }
.shopCard.saleCard { box-shadow: inset 0 0 0 2px var(--warn); }
.shopEmoji { font-size: 1.6rem; flex: 0 0 38px; text-align: center; }
.shopInfo { flex: 1; min-width: 0; }
.shopName { font-weight: 700; font-size: .86rem; }
.cnt { color: var(--led); font-size: .74rem; }
.shopDesc { font-size: .72rem; color: var(--ink-dim); margin-top: 2px; }
.salePrice { color: var(--warn); font-weight: 800; }
.buyBtn { background: linear-gradient(135deg, #ffd76e, #ffb84d); color: #4a2c00; font-weight: 800; padding: 9px 13px; border-radius: 11px; font-size: .8rem; white-space: nowrap; }
.buyBtn:disabled { background: #2c335f; color: var(--ink-dim); cursor: default; }
.lockNote { font-size: .7rem; color: var(--ink-dim); white-space: nowrap; }

/* badges */
#badgeGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; margin-top: 8px; }
.badge { background: var(--card-2); border-radius: 12px; padding: 11px 8px; text-align: center; opacity: .45; }
.badge.earned { opacity: 1; box-shadow: inset 0 0 0 2px rgba(255,206,84,.6); }
.bIcon { font-size: 1.5rem; } .bName { font-weight: 700; font-size: .76rem; margin: 4px 0 2px; } .bDesc { font-size: .64rem; color: var(--ink-dim); }
#statsRow { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 12px; font-size: .76rem; color: var(--ink-dim); }

/* learn + settings */
.learnCard { background: var(--card-2); border-radius: 12px; margin-bottom: 8px; padding: 0 12px; }
.learnCard summary { padding: 11px 0; font-weight: 700; font-size: .86rem; cursor: pointer; }
.learnCard p { padding: 0 0 12px; font-size: .8rem; line-height: 1.55; color: var(--ink-dim); }
.settingsRow { display: flex; align-items: center; gap: 10px; background: var(--card-2); border-radius: 12px; padding: 11px 12px; margin-bottom: 8px; font-size: .84rem; }
.settingsRow label { flex: 1; }
.switch { width: 44px; height: 24px; border-radius: 99px; background: #12173a; position: relative; transition: .2s; }
.switch.on { background: var(--good); }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: .2s; }
.switch.on::after { left: 23px; }
#resetBtn { margin-top: 10px; background: #4a2438; color: #ffb3c8; padding: 10px 16px; border-radius: 11px; font-size: .8rem; font-weight: 700; }
.legacyNote { margin-top: 14px; font-size: .74rem; color: var(--ink-dim); }
.legacyNote a { color: var(--led); }

/* toasts */
#toasts { position: fixed; top: 44px; left: 50%; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 6px; width: min(92vw, 380px); pointer-events: none; }
.toast { background: #2d366e; color: var(--ink); padding: 9px 14px; border-radius: 12px; font-size: .8rem; font-weight: 600; opacity: 0; transform: translateY(-8px); transition: .35s; box-shadow: 0 4px 18px rgba(0,0,10,.4); }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.good { background: #1d4d34; color: #b8f2c9; }
.toast.bad { background: #572430; color: #ffc2c9; }

/* modal */
#modalWrap { position: fixed; inset: 0; z-index: 80; background: rgba(8,10,26,.72); display: none; align-items: center; justify-content: center; padding: 18px; }
#modalWrap.show { display: flex; }
#modal { background: var(--card); border-radius: 18px; max-width: 440px; width: 100%; max-height: 86vh; overflow-y: auto; padding: 18px; box-shadow: 0 10px 50px rgba(0,0,20,.6); }
#modal h2 { font-size: 1.1rem; margin-bottom: 10px; }
#modal .mBody { font-size: .86rem; line-height: 1.5; color: var(--ink-dim); }
#modal .mRow { display: flex; gap: 8px; margin-top: 14px; }
#modal .mBtn { flex: 1; background: linear-gradient(135deg, #3fa7ff, #2bd4a4); color: #04222c; font-weight: 800; padding: 12px; border-radius: 12px; font-size: .9rem; }
#modal .mBtn.warnBtn { background: linear-gradient(135deg, #ff8c6b, #ff5252); color: #fff; }
#modal .mList { margin: 8px 0; }
#modal .mList div { padding: 4px 0; font-size: .84rem; }
#modal .certImg { width: 100%; border-radius: 12px; margin-bottom: 10px; }
#modal .bigDay { font-size: 1.8rem; font-weight: 800; text-align: center; margin: 6px 0; }
#modal .weatherLine { text-align: center; color: var(--ink-dim); font-size: .85rem; margin-bottom: 8px; }
#modal .coinsBig { text-align: center; font-size: 1.3rem; font-weight: 800; color: var(--warn); margin: 8px 0; }

/* splash */
#splash { position: fixed; inset: 0; z-index: 100; background: #0d1230 center/cover no-repeat; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding: 28px; }
#splash::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(13,18,48,.15), rgba(13,18,48,.88) 78%); }
#splash > * { position: relative; }
#splashTitle { font-size: 2rem; font-weight: 800; text-shadow: 0 2px 14px rgba(0,0,0,.7); margin-bottom: 4px; text-align: center; }
#splashSub { color: #cfe0ff; font-size: .9rem; margin-bottom: 18px; text-align: center; text-shadow: 0 1px 8px rgba(0,0,0,.8); }
#splash .flags { margin-bottom: 18px; }
#splash .flag svg { width: 40px; height: 27px; }
#nameInput { position: relative; background: rgba(255,255,255,.92); border: none; border-radius: 12px; padding: 12px 16px;
  font-size: 1rem; font-family: inherit; text-align: center; width: min(78vw, 280px); margin-bottom: 14px; color: #1c2450; font-weight: 700; }
#nameInput::placeholder { color: #8892b8; font-weight: 400; }
#startBtn { background: linear-gradient(135deg, #ffb84d, var(--amphora)); color: #3a1c00; font-size: 1.1rem; font-weight: 800; padding: 14px 44px; border-radius: 999px; box-shadow: 0 6px 26px rgba(255,140,66,.55); }

/* mini-game overlay */
.mgOverlay { position: fixed; inset: 0; z-index: 90; background: #10142e; display: flex; flex-direction: column; }
.mgHead { display: flex; align-items: center; gap: 10px; padding: 10px 14px; }
.mgTitle { font-weight: 800; font-size: 1rem; }
.mgTimer { margin-left: auto; font-weight: 700; font-size: .95rem; color: var(--warn); }
.mgQuit { font-size: 1.2rem; padding: 4px 10px; background: var(--card); border-radius: 10px; }
.mgInstr { padding: 0 14px 8px; font-size: .8rem; color: var(--ink-dim); min-height: 2.1em; }
.mgCanvas { flex: 1; width: 100%; touch-action: none; }
.mgVerdict { position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%); font-size: 1.6rem; font-weight: 800;
  background: var(--card); padding: 18px 30px; border-radius: 18px; box-shadow: 0 8px 40px rgba(0,0,20,.6); animation: popIn .3s; }
.mgVerdict.perfect { box-shadow: 0 0 0 3px var(--warn), 0 8px 40px rgba(255,206,84,.4); }
@keyframes popIn { from { transform: translate(-50%, -50%) scale(.6); opacity: 0; } }

/* profile modal */
.profileHead { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.profileAvatar { width: 52px; height: 52px; border-radius: 50%; background: linear-gradient(135deg, #3fa7ff, #2bd4a4);
  display: flex; align-items: center; justify-content: center; font-size: 1.5rem; font-weight: 800; color: #04222c; }
.profileName { font-size: 1.1rem; font-weight: 800; }
.profileSub { font-size: .78rem; color: var(--ink-dim); }
.statGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 10px 0; }
.statCell { background: var(--card-2); border-radius: 10px; padding: 8px 10px; font-size: .74rem; color: var(--ink-dim); }
.statCell b { display: block; color: var(--ink); font-size: .95rem; }
#modal #badgeGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(105px, 1fr)); gap: 6px; margin-top: 8px; }

@media (min-width: 640px) {
  .careGrid { grid-template-columns: 1fr 1fr 1fr; }
}
