/* เต่าตาบอด — old sea paper UI (Boss 2026-11-21): every panel is the SAME torn paper sheet, 9-sliced (corners + edges keep their
   torn shape at any size), dark-brown ink, Thai looped fonts: Srisakdi (titles, old-manuscript feel) + Taviraj (text). Swap the sheet
   in one place: --paper / --paper-slice. */
:root {
  --paper: url(assets/paper.svg); --paper-slice: 70; --edge: 22px;
  --ink: #3a2312; --ink-soft: #6b4a2c; --ink-faint: rgba(58, 35, 18, .18);
  --rust: #6b4423; --seal: #3f2410; --olive: #5d7a2a; --sea: #2f5d7c; --gold: #f3c969;
  --on-sea: #f4e4c1; --deep: #06223a;
  --title: 'Srisakdi', 'Taviraj', serif; --text: 'Taviraj', 'Sarabun', serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--deep); color: var(--ink); font-family: var(--text); }
#c { position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; outline: none; }
button { font: inherit; color: inherit; cursor: pointer; }

/* ── the paper sheet ── */
.paper, #toast, #prompt, #banner, #mini, .card, #btns button {
  border: var(--edge) solid transparent;
  border-image: var(--paper) var(--paper-slice) fill / var(--edge) / 0 stretch;
  background: none; color: var(--ink);
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, .45));
}
/* text that sits straight on the sea (no paper) */
#zone, #keys, #depth, #stats, #hunt { color: var(--on-sea); text-shadow: 0 1px 3px #000, 0 0 8px rgba(0, 0, 0, .6); }

#hud { position: fixed; inset: 0; pointer-events: none; }
#hud button, #pad { pointer-events: auto; }
/* floating HP + stamina bars straight on the sea (no paper); each bar's length = its max (--w), so it grows */
#stats { position: absolute; left: 16px; top: 14px; }
.fbar { display: grid; grid-template-columns: auto auto; justify-content: start; gap: 2px 10px; font-size: 13px; font-weight: 600; width: var(--w, 180px); max-width: calc(100vw - 200px); transition: width .4s ease; }
.fbar + .fbar { margin-top: 8px; }
.fbar b { text-align: right; font-variant-numeric: tabular-nums; justify-self: end; }
.fbar { grid-template-columns: 1fr auto; }
.fbar i { grid-column: 1 / -1; height: 10px; border-radius: 5px; background: rgba(0, 0, 0, .42); overflow: hidden; box-shadow: 0 0 0 1px rgba(244, 228, 193, .35), 0 2px 6px rgba(0, 0, 0, .5); }
.fbar em { display: block; height: 100%; width: 100%; border-radius: inherit; transition: width .12s linear; }
#lvv { font-family: var(--title); font-size: 22px; font-weight: 700; color: #ffe2a0; margin-bottom: 4px; }
/* the XP line: a yellow bar centred at the bottom, 70% of the screen wide; full = a level up */
#xpline { position: absolute; left: 15%; width: 70%; bottom: 8px; height: 8px; border-radius: 4px; background: rgba(0, 0, 0, .5); box-shadow: 0 0 0 1px rgba(255, 215, 106, .35); }
#xpline em { border-radius: inherit; }
#xpline em { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #b08a2c, #ffd76a 70%, #fff1b8); box-shadow: 0 0 10px rgba(255, 215, 106, .6); transition: width .35s ease; }
#xpv { position: absolute; left: 50%; transform: translateX(-50%); bottom: 12px; font-size: 12px; font-weight: 600; color: #ffe2a0; text-shadow: 0 1px 3px #000; font-variant-numeric: tabular-nums; }
#hp em { background: linear-gradient(90deg, #8e1c14, #e0533c); }
#hp em.low { animation: pulse .8s ease-in-out infinite; }
#sta em { background: linear-gradient(90deg, #1f5a80, #5fb4e0); }
#sta em.low { background: linear-gradient(90deg, #6e1f10, var(--rust)); }
@keyframes pulse { 50% { opacity: .55; } }
#sleep { margin-top: 6px; font-size: 13px; color: #ffcf8a; font-weight: 600; }
/* bottom-left: the rank button + how long this turtle has been looking for the yoke (not its age) */
#bl { position: absolute; left: 16px; bottom: 46px; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
#rankbtn { pointer-events: auto; padding: 6px 14px; border-radius: 18px; border: 1px solid rgba(244, 228, 193, .5); background: rgba(20, 30, 40, .55); color: var(--on-sea); font-weight: 700; font-size: 14px; }
#bl .blrow { display: flex; gap: 6px; }
#sndbtn { pointer-events: auto; padding: 6px 12px; border-radius: 18px; border: 1px solid rgba(244, 228, 193, .5); background: rgba(20, 30, 40, .55); color: var(--on-sea); font-weight: 700; font-size: 14px; }
#sndbtn[aria-pressed="false"] { opacity: .7; }
#rankbtn:hover, #rankbtn:focus-visible, #sndbtn:hover, #sndbtn:focus-visible { background: rgba(58, 35, 18, .75); outline: none; }
#hunt { font-family: var(--title); font-size: 17px; font-weight: 700; }
.ranks { list-style: none; margin: 8px 0 0; padding: 0; max-height: 50vh; overflow-y: auto; }
.ranks li { display: grid; grid-template-columns: 2.2em 1fr auto; gap: 8px; padding: 6px 4px; border-bottom: 1px dashed var(--ink-faint); }
.ranks li.me { font-weight: 700; color: var(--seal); }
.ranks .n { text-align: right; font-variant-numeric: tabular-nums; }
.myrank { text-align: center; font-size: 18px; margin: 6px 0 0; }

#mapwrap { position: absolute; right: 16px; top: 16px; width: 160px; text-align: center; pointer-events: auto; cursor: pointer; }
#mapwrap:hover #map { transform: scale(1.04); } #map { transition: transform .15s ease; }
#map { width: 160px; height: 160px; border-radius: 50%; display: block; filter: drop-shadow(0 4px 10px rgba(0,0,0,.5)); }
#zone { font-size: 13px; margin-top: 4px; }
#depth { position: absolute; right: 186px; top: 24px; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; }
#depthbar { position: relative; width: 8px; height: 120px; border-radius: 4px; background: linear-gradient(#8fd6f0, #0b3a5c 60%, #c8b07a); opacity: .9; }
#depthdot { position: absolute; left: 50%; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%; background: var(--gold); border: 2px solid #3a2312; }

#banner { position: absolute; left: 50%; top: 8px; transform: translateX(-50%); padding: 0 8px; font-family: var(--text); font-weight: 700; white-space: nowrap; color: var(--seal); }
#toast { position: absolute; left: 50%; top: 66px; transform: translateX(-50%); padding: 0 6px; font-size: 15px; max-width: min(92vw, 540px); text-align: center; }
#prompt { position: absolute; left: 50%; bottom: 120px; transform: translateX(-50%); padding: 0 6px; font-weight: 700; color: var(--seal); }
/* the message-in-a-bottle (a turtle can't carry a book): bobs on the water, tap = the scroll unrolls */
#bookbtn { position: absolute; right: 24px; bottom: 30px; width: 58px; height: 80px; padding: 0; border: 0; background: none; filter: drop-shadow(0 4px 8px rgba(0,0,0,.55)); animation: bob 3.2s ease-in-out infinite; }
#bookbtn svg { width: 100%; height: 100%; display: block; }
#bookbtn:hover, #bookbtn:focus-visible { animation-play-state: paused; transform: rotate(-8deg) scale(1.08); outline: none; }
@keyframes bob { 0%, 100% { transform: translateY(0) rotate(0); } 50% { transform: translateY(-6px) rotate(4deg); } }
.card.unroll { animation: unroll .55s cubic-bezier(.2,.8,.3,1) both; transform-origin: 50% 0; }
@keyframes unroll { from { clip-path: inset(0 0 100% 0); transform: scaleY(.6); } 60% { transform: scaleY(1.02); } to { clip-path: inset(0 0 0 0); transform: none; } }
/* slim one-line paper strips need a thinner torn edge or the 9-slice tears apart */
#toast, #prompt, #banner { --edge: 14px; padding: 4px 12px; }
#keys { position: absolute; left: 16px; bottom: 22px; font-size: 13px; }

#pad { position: absolute; left: 24px; bottom: 40px; width: 120px; height: 120px; border-radius: 50%; border: 2px solid rgba(244,228,193,.45); background: rgba(58,35,18,.3); display: none; touch-action: none; }
#stick { position: absolute; left: 40px; top: 40px; width: 40px; height: 40px; border-radius: 50%; background: rgba(244,228,193,.7); }
#btns { position: absolute; right: 16px; bottom: 30px; display: none; grid-template-columns: 70px 100px; gap: 8px; align-items: end; }
#btns button { pointer-events: auto; height: 70px; padding: 0; font-family: var(--title); font-weight: 700; font-size: 17px; touch-action: none; --edge: 16px; }
#btns #b-act { grid-column: 1 / -1; grid-row: 1; height: 58px; color: var(--seal); }
#btns #b-swim { height: 100px; font-size: 22px; }
body.touch #pad { display: block; }
body.touch #btns { display: grid; }
body.touch #keys { display: none; }
body.touch #bl { bottom: 176px; }
body.touch #bookbtn { bottom: 230px; }

#mini { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: min(92vw, 460px); padding: 4px 6px; text-align: center; }
.mini-title { font-family: var(--title); font-size: 20px; font-weight: 700; margin-bottom: 10px; }
.bar { position: relative; height: 26px; border-radius: 13px; background: var(--ink-faint); overflow: hidden; box-shadow: inset 0 1px 2px rgba(58,35,18,.35); }
#gap { position: absolute; top: 0; bottom: 0; background: rgba(93, 122, 42, .6); }
#needle { position: absolute; top: -2px; bottom: -2px; width: 4px; margin-left: -2px; background: var(--seal); }
#minimsg { margin-top: 8px; font-size: 13px; color: var(--ink-soft); }
#mini.miss { animation: shake .3s; }
@keyframes shake { 25% { transform: translate(-52%, -50%); } 75% { transform: translate(-48%, -50%); } }

/* ── sheets: start, modals ── */
.sheet { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; background: rgba(2, 12, 22, .55); overflow-y: auto; }
.sheet[hidden] { display: none; }
.card { width: min(100%, 540px); padding: 6px 10px; line-height: 1.65; --edge: 34px; }
.card h1 { margin: 0; font-family: var(--title); font-size: 40px; line-height: 1.2; color: var(--seal); }
.card h2 { margin: 0 0 8px; font-family: var(--title); font-size: 26px; line-height: 1.3; color: var(--seal); }
.sub { font-family: var(--title); color: var(--ink-soft); font-size: 18px; margin: 0 0 10px; }
.lead { color: var(--ink); margin: 0 0 10px; }
.rules { margin: 0 0 14px; padding-left: 20px; font-size: 14px; }
.rules li::marker { color: var(--rust); }
.f { display: block; margin: 10px 0 6px; font-weight: 700; }
.f input { display: block; width: 100%; margin-top: 4px; padding: 8px 4px; border: 0; border-bottom: 2px dashed var(--ink-soft); background: transparent; color: var(--ink); font: inherit; font-size: 18px; outline: none; }
.f input::placeholder { color: rgba(58,35,18,.45); }
#looks { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.look { padding: 6px 2px; border-radius: 10px; border: 2px solid var(--ink-faint); background: rgba(255, 246, 220, .25); font-size: 12px; text-align: center; color: var(--ink); }
.look i { display: block; width: 32px; height: 22px; margin: 0 auto 4px; border-radius: 50% 50% 40% 40%; border: 1px solid rgba(58,35,18,.4); }
.look[aria-pressed="true"] { border-color: var(--seal); background: rgba(63, 36, 16, .12); }
/* the main button = a red wax-seal stamp */
.primary { display: block; width: 100%; margin-top: 16px; padding: 11px; border: 0; border-radius: 10px 14px 9px 13px; background: radial-gradient(circle at 30% 30%, #6a4524, #3f2410 75%); color: #f7e7c4; font-family: var(--text); font-weight: 700; font-size: 19px; box-shadow: 0 2px 0 #24140a, inset 0 0 0 2px rgba(247,231,196,.22); }
.primary:disabled { opacity: .7; }
.ghost { padding: 6px 14px; border-radius: 10px; border: 1.5px solid var(--ink-soft); background: transparent; color: var(--ink); }
.fine { font-size: 12px; color: var(--ink-soft); margin: 12px 0 0; }
.fine a { color: var(--rust); }
.src { font-size: 13px; color: var(--rust); margin-top: 8px; font-style: italic; }
.gist { font-size: 12px; color: var(--ink-soft); }
.quote { font-size: 19px; margin: 10px 0; }
.tabs { display: flex; gap: 6px; margin: 8px 0 12px; flex-wrap: wrap; }
.tabs button { padding: 4px 12px; border-radius: 999px; border: 1.5px solid var(--ink-soft); background: transparent; color: var(--ink); }
.tabs button[aria-pressed="true"] { background: rgba(63, 36, 16, .14); border-color: var(--seal); color: var(--seal); font-weight: 700; }
.entries { display: grid; gap: 8px; max-height: 55vh; overflow-y: auto; }
.entry { padding: 8px 10px; border-radius: 8px; border: 1px dashed rgba(58,35,18,.35); background: rgba(255, 246, 220, .2); }
.entry.locked { opacity: .5; }
.entry b { display: block; font-family: var(--title); font-size: 18px; color: var(--seal); }
.row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.trophy { font-size: 46px; text-align: center; }
/* the treasure map (tap the minimap): a wide sheet, the sea drawn square inside it */
.card.mapcard { width: min(100%, 760px); }
#tmap { display: block; width: min(100%, 64vh); aspect-ratio: 1; margin: 4px auto 0; }
.maplegend { margin: 6px 0 0; font-size: 13px; color: var(--ink-soft); text-align: center; }
/* the sutta told at the first birth */
.scroll-h { text-align: center; font-size: 13px; letter-spacing: .1em; color: var(--ink-soft); }
.intro-t { text-align: center; font-size: 32px !important; }
.intro p { margin: 0 0 8px; text-indent: 1.5em; }
.you { margin: 12px 0 0; padding-top: 10px; border-top: 1.5px dashed var(--ink-soft); font-weight: 600; }

@media (max-width: 600px) {
  #hunt { font-size: 14px; }
  #mapwrap, #map { width: 120px; }
  #map { height: 120px; }
  #bookbtn { right: 16px; bottom: 16px; width: 46px; height: 64px; }
  #banner { top: auto; bottom: 190px; font-size: 14px; }
  #depth { right: 144px; top: 20px; }
  #depthbar { height: 90px; }
  .card { --edge: 24px; }
  .card h1 { font-size: 34px; }
}

/* ── login + choose-your-turtle ── */
.login { text-align: center; }
.login .lead { text-align: left; }
.g { display: inline-grid; place-items: center; width: 28px; height: 28px; margin-right: 6px; border-radius: 50%; background: #f7e7c4; color: #3f2410; font-family: Georgia, serif; font-weight: 700; font-size: 18px; vertical-align: 2px; }
.ghost.wide { display: block; width: 100%; margin-top: 10px; padding: 8px; }
#create { position: fixed; inset: 0; pointer-events: none; }
#create[hidden] { display: none; }
#create > * { pointer-events: auto; }
.create-card { position: absolute; left: max(16px, 5vw); top: 50%; transform: translateY(-50%); width: min(420px, 44vw); max-height: calc(100vh - 32px); overflow-y: auto; }
.pick { display: flex; align-items: center; gap: 10px; }
#lookname { flex: 1; text-align: center; font-family: var(--title); font-size: 26px; font-weight: 700; color: var(--seal); }
.arrow { width: 44px; height: 44px; border-radius: 50%; border: 2px solid var(--ink-soft); background: rgba(255, 246, 220, .3); color: var(--ink); font-size: 28px; line-height: 1; padding: 0 0 4px; }
.arrow:hover { background: rgba(63, 36, 16, .15); }
.arrow.big { position: absolute; top: 50%; width: 58px; height: 58px; margin-top: -29px; font-size: 40px; border-color: rgba(244,228,193,.7); background: rgba(58,35,18,.45); color: var(--on-sea); }
#prev2 { left: calc(max(16px, 5vw) + min(420px, 44vw) + 24px); }
#next2 { right: max(16px, 4vw); }
.looknote { text-align: center; margin: 4px 0 2px; font-size: 14px; color: var(--ink-soft); min-height: 1.5em; }
.dots { display: flex; justify-content: center; gap: 6px; margin-bottom: 6px; }
.dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--ink-faint); }
.dots i.on { background: var(--seal); }
@media (max-width: 760px) {
  .create-card { left: 12px; right: 12px; top: auto; bottom: 12px; transform: none; width: auto; max-height: 56vh; }
  .create-card .rules { display: none; }
  #prev2 { left: 12px; top: 22%; } #next2 { right: 12px; top: 22%; }
}

/* ── the shark's grab (Boss 2026-11-21): a pulsing Space key + the struggle meter; touch = one big tappable button ── */
#grab { position: absolute; left: 50%; top: 30%; transform: translateX(-50%); text-align: center; pointer-events: none; color: var(--on-sea); text-shadow: 0 1px 3px #000, 0 0 10px rgba(0,0,0,.7); }
.grab-t { font-family: var(--title); font-size: 22px; font-weight: 700; line-height: 1.5; }
.grab-t b { display: block; font-size: 26px; color: var(--gold); }
.grab-tap { display: none !important; }
body.touch .grab-k { display: none; } body.touch .grab-tap { display: block !important; }
#grab kbd { display: inline-block; min-width: 128px; padding: 4px 18px; margin: 4px 4px 0; border-radius: 10px; font: 700 20px/1.4 var(--text); color: var(--seal); text-shadow: none;
  background: linear-gradient(#f6ead0, #dcc596); border: 2px solid #6b4423; box-shadow: 0 5px 0 #6b4423, 0 8px 14px rgba(0,0,0,.5); animation: keyPress .42s ease-in-out infinite; }
@keyframes keyPress { 50% { transform: translateY(4px); box-shadow: 0 1px 0 #6b4423, 0 3px 6px rgba(0,0,0,.5); } }
.grab-m { width: min(70vw, 300px); height: 14px; margin: 10px auto 0; border-radius: 7px; background: rgba(6,34,58,.6); border: 1px solid rgba(244,228,193,.6); overflow: hidden; }
#grabbar { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #5d7a2a, #b7d36a); transition: width .08s linear; }
#grab.jolt { animation: jolt .14s; }
@keyframes jolt { 40% { transform: translateX(-50%) scale(1.06) rotate(-2deg); } }
#b-struggle { position: absolute; right: 22px; bottom: 34px; width: 150px; height: 150px; border-radius: 50%; pointer-events: auto; touch-action: none; display: none;
  font-family: var(--title); font-size: 34px; font-weight: 700; color: var(--seal); background: radial-gradient(circle at 40% 35%, #f6ead0, #d3b77e); border: 3px solid #6b4423;
  box-shadow: 0 6px 0 #6b4423, 0 10px 20px rgba(0,0,0,.55); animation: pulse .5s ease-in-out infinite; }
#b-struggle:active { transform: translateY(4px); box-shadow: 0 2px 0 #6b4423; }
body.touch #b-struggle:not([hidden]) { display: block; }
body.touch.held #btns { visibility: hidden; }
