:root {
  --ink: #24435c;
  --card: #fffaf2;
  --accent: #ff8a5c;
  --accent-dark: #d9663c;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  background: #123f4a;
  font-family: 'Fredoka', ui-rounded, 'SF Pro Rounded', 'Nunito', system-ui, sans-serif;
  color: var(--ink);
  user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}
button { font-family: inherit; color: var(--ink); }
[hidden] { display: none !important; }

/* the edges of the front glass: a little darkness and the silicone seam, so the screen reads as the tank side */
#glass {
  position: fixed; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 0 3px rgba(10, 30, 35, .55), inset 0 0 90px 10px rgba(4, 25, 32, .55);
}
#loading {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: #123f4a; color: #dff6ff; font-size: 26px; font-weight: 600; z-index: 20;
}
#c { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; cursor: pointer; }

#top {
  position: fixed; top: max(10px, env(safe-area-inset-top)); left: 10px; right: 10px;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 8px;
  pointer-events: none;
}
#top > * { pointer-events: auto; }
#hud, #care, #corner { display: flex; gap: 6px; align-items: center; }
#care { flex-wrap: wrap; justify-content: center; }
#hud span, .pill, #care-msg {
  background: var(--card); border-radius: 999px; padding: 6px 12px;
  font-weight: 600; font-size: 16px; box-shadow: 0 3px 0 rgba(0,0,0,.08); white-space: nowrap;
}
.pill { transition: background .3s; }
.pill.done { background: #c9f2c4; }
.pill.done::after { content: ' ✓'; color: #2e9e4a; }
#care-msg { background: #fff1b8; }
#care-msg:empty { display: none; }
.round {
  width: 46px; height: 46px; border-radius: 50%; border: none; background: var(--card);
  font-size: 22px; box-shadow: 0 3px 0 rgba(0,0,0,.1); cursor: pointer;
}
.round:active { transform: translateY(2px); }

#tools {
  position: fixed; bottom: max(14px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%);
  display: flex; gap: 8px; padding: 8px;
  background: rgba(255,250,242,.9); border-radius: 30px; box-shadow: 0 6px 20px rgba(0,0,0,.14);
}
.tool {
  border: none; background: transparent; border-radius: 22px; padding: 6px 14px;
  display: flex; flex-direction: column; align-items: center; cursor: pointer;
  transition: transform .15s, background .15s;
}
.tool span { font-size: 34px; line-height: 1.15; }
.tool b { font-size: 14px; font-weight: 600; }
.tool.active { background: #ffd9a8; transform: translateY(-4px) scale(1.06); }

#drawer {
  position: fixed; bottom: 108px; left: 50%; transform: translateX(-50%);
  max-width: calc(100vw - 20px); padding: 8px;
  background: rgba(255,250,242,.94); border-radius: 22px; box-shadow: 0 6px 20px rgba(0,0,0,.14);
}
#drawer-items { display: flex; gap: 8px; overflow-x: auto; padding: 6px 2px 2px; touch-action: pan-x; scrollbar-width: thin; }
.item {
  flex: 0 0 auto; width: 72px; height: 72px; border: 3px solid transparent; border-radius: 16px;
  background: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer; position: relative; padding: 2px;
}
.item .ic { font-size: 30px; line-height: 1.1; }
.item small { font-size: 11px; font-weight: 600; text-align: center; line-height: 1.1; }
.item.sel { border-color: var(--accent); background: #fff1e6; }
.item.locked { opacity: .55; }
.item.locked .ic { filter: grayscale(1) brightness(1.1) !important; }
.item.locked::after { content: '🔒'; position: absolute; top: 2px; right: 4px; font-size: 13px; }
.item.new::before {
  content: 'NEW'; position: absolute; top: -7px; left: -4px; background: #ff5c8a; color: #fff;
  font-size: 10px; font-weight: 700; padding: 1px 5px; border-radius: 6px;
}

#selmenu {
  position: fixed; bottom: 216px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px;
}
#selmenu button {
  font-size: 17px; font-weight: 600; border: none; border-radius: 999px; padding: 10px 16px;
  background: var(--card); box-shadow: 0 4px 0 rgba(0,0,0,.12); cursor: pointer; white-space: nowrap;
}
#selmenu button[data-act="done"] { background: #c9f2c4; }

#cleanmeter {
  position: fixed; top: 64px; left: 50%; transform: translateX(-50%);
  background: #e3f7ff; padding: 6px 14px; border-radius: 999px; font-weight: 700; font-size: 17px;
  box-shadow: 0 3px 0 rgba(0,0,0,.08);
}

#cursor {
  position: fixed; left: 0; top: 0; font-size: 46px; pointer-events: none; display: none; z-index: 5;
  margin: -28px 0 0 -23px; filter: drop-shadow(0 4px 4px rgba(0,0,0,.25));
}
#cursor.shake { animation: shake .35s; }
#cursor.scrub { animation: scrub .25s infinite; }
@keyframes shake { 0% { transform: rotate(0); } 30% { transform: rotate(-40deg); } 65% { transform: rotate(20deg); } 100% { transform: rotate(0); } }
@keyframes scrub { 0%, 100% { transform: rotate(-12deg); } 50% { transform: rotate(12deg); } }

.tag {
  position: fixed; left: 0; top: 0; background: var(--card); padding: 4px 12px; border-radius: 14px;
  text-align: center; opacity: 0; transition: opacity .2s; pointer-events: none; box-shadow: 0 3px 8px rgba(0,0,0,.15);
  z-index: 4;
}
.tag.show { opacity: 1; }
.tag b { display: block; font-size: 17px; }
.tag small { font-size: 12px; opacity: .75; }

#toast {
  position: fixed; top: 110px; left: 50%; transform: translate(-50%, -16px);
  background: #fff; padding: 10px 18px; border-radius: 18px; font-weight: 600; font-size: 19px;
  opacity: 0; transition: opacity .3s, transform .3s; pointer-events: none; box-shadow: 0 6px 18px rgba(0,0,0,.15);
  max-width: calc(100vw - 30px); text-align: center; z-index: 6;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

#modal, #book {
  position: fixed; inset: 0; background: rgba(20,50,80,.45); display: flex; align-items: center; justify-content: center;
  z-index: 10; padding: 16px;
}
.card {
  background: var(--card); border-radius: 28px; padding: 22px 24px; max-width: 430px; width: 100%;
  text-align: center; box-shadow: 0 20px 50px rgba(0,0,0,.25); animation: popin .4s cubic-bezier(.3,1.6,.5,1);
  max-height: 92vh; overflow: auto;
}
.card.wide { max-width: 780px; }
@keyframes popin { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.card h1 { font-size: 30px; margin: .15em 0 .2em; }
.card p { font-size: 19px; line-height: 1.4; margin: .5em 0; }
.card .sun { font-size: 54px; line-height: 1; }
.card img.fishpic { width: 230px; max-width: 70%; height: auto; display: block; margin: 0 auto; animation: bob 2s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-6px) rotate(-2deg); } }
.unlocks { background: #fff1e0; border-radius: 18px; padding: 8px 10px; margin-top: 10px; }
.unlocks p { font-size: 16px; margin: 0 0 4px; }
.unlocks .ics { font-size: 34px; letter-spacing: 6px; }
.big {
  font-size: 22px; font-weight: 700; border: none; background: var(--accent); color: #fff;
  padding: 12px 30px; border-radius: 999px; box-shadow: 0 5px 0 var(--accent-dark); cursor: pointer; margin-top: 12px;
}
.big:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--accent-dark); }

#book-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 10px; margin: 12px 0; }
.bk { background: #fff; border-radius: 16px; padding: 6px 4px 8px; }
.bk img { width: 100%; display: block; aspect-ratio: 16 / 11; object-fit: contain; }
.bk.no img { filter: brightness(0) opacity(.16); }
.bk small { font-weight: 600; font-size: 12px; display: block; }
.bk.no small { opacity: .5; }

#debug { position: fixed; right: 12px; bottom: 120px; display: flex; flex-direction: column; gap: 6px; }
#debug button { border: none; border-radius: 12px; padding: 8px 12px; background: #333; color: #fff; font-weight: 600; cursor: pointer; }

@media (max-width: 600px) {
  .tool { padding: 4px 9px; }
  .tool span { font-size: 28px; }
  .tool b { font-size: 12px; }
  #hud span, .pill, #care-msg { font-size: 13px; padding: 5px 9px; }
  #drawer { bottom: 96px; }
  #selmenu { bottom: 196px; }
  .item { width: 68px; height: 74px; }
  .round { width: 40px; height: 40px; font-size: 19px; }
}
/* signature move line on the fish tag and in the fish book */
.tag small.mv, .bk small.mv { opacity: 1; color: #e8590c; font-weight: 600; }

/* name tags can be tapped to rename the fish */
.tag.show { pointer-events: auto; cursor: pointer; }
.tag .ed { font-size: 13px; opacity: .7; }
/* fish book: each fish's name is a rename button */
.bk .nms { display: flex; flex-wrap: wrap; gap: 3px; justify-content: center; margin: 3px 0; }
.bk .nm { border: none; background: #eaf6ff; border-radius: 999px; padding: 2px 8px; font-family: inherit; font-weight: 600; font-size: 12px; color: #234; cursor: pointer; }
.linkbtn { border: none; background: none; color: var(--accent-dark); font-family: inherit; font-weight: 600; font-size: 16px; cursor: pointer; text-decoration: underline; padding: 4px; }
.namein {
  font-family: inherit; font-weight: 700; font-size: 26px; text-align: center; width: 100%; max-width: 300px;
  border: 3px solid #cfe6f5; border-radius: 18px; padding: 8px 12px; margin-top: 6px; outline: none; color: #234;
}
.namein:focus { border-color: var(--accent); }
/* settings */
.setrow {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%;
  border: none; background: #fff; border-radius: 18px; padding: 12px 16px; font-family: inherit; font-weight: 600; font-size: 19px; color: #234; cursor: pointer;
}
.sw { width: 52px; height: 30px; border-radius: 999px; background: #c9d3da; position: relative; flex: none; transition: background .2s; }
.sw::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25); }
.sw.on { background: #3cb371; }
.sw.on::after { transform: translateX(22px); }
.card p.hint { font-size: 15px; opacity: .7; }

/* the naming card opens from inside the fish book, so it sits above it */
#modal { z-index: 11; }
