/* ============================================================
   Deep Bite — UI styles
   Layout: full-bleed canvas; HUD pinned to the corners with safe-area insets;
   start / death screens are centered glass cards over the water.
   Single committed dark-ocean look (a game), so no light theme.
   ============================================================ */
:root {
  --bg: #061f36;
  --surface: rgba(6, 30, 56, 0.72);
  --surface-2: rgba(10, 48, 84, 0.88);
  --line: rgba(130, 200, 255, 0.22);
  --fg: #eaf6ff;
  --muted: #8fb3cc;
  --accent: #ffb020;        /* amber — the pellet glow */
  --accent-ink: #2a1600;
  --cyan: #4fd8ff;
  --danger: #ff6b6b;
  --font-display: 'Fredoka', 'Nunito', system-ui, sans-serif;
  --font-body: 'Nunito', 'Segoe UI', system-ui, sans-serif;
  --sa-t: env(safe-area-inset-top, 0px);
  --sa-b: env(safe-area-inset-bottom, 0px);
  --sa-l: env(safe-area-inset-left, 0px);
  --sa-r: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 15px;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

#app { position: fixed; inset: 0; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: crosshair; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; font-variant-numeric: tabular-nums; }
.hud-stats {
  position: absolute; top: calc(12px + var(--sa-t)); left: max(16px, var(--sa-l));
  display: flex; gap: 8px;
}
.stat {
  background: var(--surface); border: 1px solid var(--line); backdrop-filter: blur(6px);
  border-radius: 12px; padding: 6px 12px; min-width: 72px;
  display: flex; flex-direction: column; gap: 0;
}
.stat .label, .hud-board .board-title, .label { font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.stat .val { font-family: var(--font-display); font-size: 22px; font-weight: 600; line-height: 1.1; }

.hud-board {
  position: absolute; top: calc(12px + var(--sa-t)); right: max(16px, var(--sa-r));
  background: var(--surface); border: 1px solid var(--line); backdrop-filter: blur(6px);
  border-radius: 12px; padding: 8px 10px 6px; min-width: 150px; max-width: 42vw;
}
.hud-board ol { list-style: none; margin: 4px 0 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.hud-board li { display: grid; grid-template-columns: 16px 1fr auto; gap: 6px; font-size: 12.5px; line-height: 1.5; min-width: 0; }
.hud-board li .pos { color: var(--muted); font-weight: 700; }
.hud-board li .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.hud-board li .ms { color: var(--cyan); font-weight: 700; }
.hud-board li.me { color: var(--accent); }
.hud-board li.me .ms { color: var(--accent); }
.hud-board .players { margin-top: 6px; font-size: 11px; color: var(--muted); }

#minimap {
  position: absolute; left: max(16px, var(--sa-l)); bottom: calc(14px + var(--sa-b));
  width: 132px; height: 132px; border-radius: 10px; opacity: 0.92;
}
#boost-btn {
  position: absolute; right: max(16px, var(--sa-r)); bottom: calc(18px + var(--sa-b));
  width: 92px; height: 92px; border-radius: 50%; border: 2px solid var(--line);
  background: var(--surface-2); color: var(--fg); font-family: var(--font-display); font-weight: 700; letter-spacing: 0.06em;
  pointer-events: auto; display: none; user-select: none; -webkit-user-select: none; touch-action: none;
}
#boost-btn.touch { display: block; }
#boost-btn.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

#feed {
  position: absolute; top: calc(14px + var(--sa-t)); left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 6px; align-items: center; max-width: min(90vw, 420px);
}
.feed-item {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px;
  font-size: 14px; animation: pop .25s ease-out; transition: opacity .4s, transform .4s;
}
.feed-item .gain { color: var(--accent); font-weight: 800; margin-left: 4px; }
.feed-item.out { opacity: 0; transform: translateY(-8px); }
@keyframes pop { from { transform: scale(.8); opacity: 0; } to { transform: scale(1); opacity: 1; } }

#hint {
  position: absolute; bottom: calc(16px + var(--sa-b)); left: 50%; transform: translateX(-50%);
  font-size: 12.5px; color: var(--muted); background: var(--surface); border-radius: 999px; padding: 5px 12px;
  white-space: nowrap; max-width: 90vw; overflow: hidden; text-overflow: ellipsis; transition: opacity 1.2s;
}
#hint.fade { opacity: 0; }

/* ---------- 가상 조이스틱 (터치) ---------- */
.joy {
  position: absolute; left: max(22px, var(--sa-l)); bottom: calc(26px + var(--sa-b));
  width: 128px; height: 128px; border-radius: 50%;
  background: rgba(6, 30, 56, 0.35); border: 2px solid rgba(130, 200, 255, 0.35);
  pointer-events: none; transition: background .15s, border-color .15s;
}
.joy::before { content: ''; position: absolute; inset: 30%; border-radius: 50%; border: 1px dashed rgba(130, 200, 255, 0.28); }
.joy-knob {
  position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; border-radius: 50%; transform: translate(-50%, -50%);
  background: rgba(79, 216, 255, 0.55); border: 2px solid rgba(234, 246, 255, 0.85); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
}
.joy.active { background: rgba(6, 30, 56, 0.55); border-color: rgba(79, 216, 255, 0.75); }
.joy.active .joy-knob { background: var(--accent); border-color: #fff; }

/* ---------- 터치 기기 HUD 배치 ----------
   위: 왼쪽 스탯 알약(질량·순위) / 오른쪽 축소 리더보드 / 그 아래 왼쪽에 킬 피드
   아래: 왼쪽 조이스틱 / 가운데 미니맵 / 오른쪽 BOOST */
body.touch .hud-stats { gap: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; backdrop-filter: blur(6px); padding: 5px 4px; }
body.touch .stat { background: none; border: 0; backdrop-filter: none; padding: 0 10px; min-width: 0; border-radius: 0; }
body.touch .stat + .stat { border-left: 1px solid var(--line); }
body.touch .stat .label { font-size: 9.5px; }
body.touch .stat .val { font-size: 17px; }
body.touch .hud-board { min-width: 128px; max-width: 42vw; padding: 6px 8px 4px; }
body.touch .hud-board .board-title { font-size: 9.5px; }
body.touch .hud-board li { font-size: 11px; line-height: 1.4; grid-template-columns: 12px 1fr auto; gap: 4px; }
body.touch .hud-board li:nth-child(n+6) { display: none; }
body.touch .hud-board .players { font-size: 9.5px; margin-top: 3px; }
body.touch #feed { top: calc(60px + var(--sa-t)); left: max(16px, var(--sa-l)); transform: none; align-items: flex-start; max-width: 56vw; }
body.touch .feed-item { font-size: 12.5px; padding: 4px 10px; }
body.touch #hint { display: none; }
body.touch #minimap { left: 50%; transform: translateX(-50%); bottom: calc(24px + var(--sa-b)); width: 84px; height: 84px; opacity: 0.8; }
body.touch #boost-btn { width: 84px; height: 84px; font-size: 13px; bottom: calc(30px + var(--sa-b)); right: max(22px, var(--sa-r)); }
body.touch #toast { bottom: auto; top: calc(104px + var(--sa-t)); }
/* 가로 모드(낮은 화면): 한 단계 더 압축 */
@media (max-height: 520px) {
  body.touch .hud-board li:nth-child(n+4) { display: none; }
  body.touch .hud-board .players { display: none; }
  body.touch #minimap { width: 64px; height: 64px; bottom: calc(16px + var(--sa-b)); }
  body.touch #boost-btn { width: 72px; height: 72px; font-size: 12px; bottom: calc(20px + var(--sa-b)); }
  body.touch .joy { width: 108px; height: 108px; bottom: calc(18px + var(--sa-b)); }
  body.touch .joy-knob { width: 44px; height: 44px; }
  body.touch #feed { top: calc(62px + var(--sa-t)); }
  body.touch #toast { top: calc(60px + var(--sa-t)); }
}
/* 좁은 화면(360px 급): 하단 세 요소가 겹치지 않게 */
@media (max-width: 400px) {
  body.touch .joy { width: 112px; height: 112px; }
  body.touch .joy-knob { width: 46px; height: 46px; }
  body.touch #minimap { width: 72px; height: 72px; }
  body.touch #boost-btn { width: 76px; height: 76px; }
}

/* ---------- Screens ---------- */
.screen {
  position: absolute; inset: 0; display: flex; flex-direction: column; gap: 12px; align-items: center; justify-content: center; justify-content: safe center;
  padding-block: calc(16px + var(--sa-t)) calc(16px + var(--sa-b));
  padding-left: max(16px, var(--sa-l)); padding-right: max(16px, var(--sa-r));
  overflow-y: auto;
  background: radial-gradient(120% 80% at 50% -10%, #1a8fc1 0%, #0b5f8e 35%, #063a60 70%, #041a33 100%);
}
#death { background: rgba(3, 14, 30, 0.6); backdrop-filter: blur(3px); }
.rays { position: absolute; inset: -20% -10%; pointer-events: none; overflow: hidden;
  background:
    linear-gradient(100deg, transparent 20%, rgba(190,235,255,.10) 24%, transparent 30%),
    linear-gradient(100deg, transparent 48%, rgba(190,235,255,.08) 53%, transparent 60%),
    linear-gradient(100deg, transparent 72%, rgba(190,235,255,.07) 76%, transparent 83%);
  animation: sway 9s ease-in-out infinite alternate;
}
@keyframes sway { from { transform: translateX(-2%) } to { transform: translateX(2%) } }
@media (prefers-reduced-motion: reduce) { .rays, .feed-item { animation: none; } }

.card {
  position: relative; width: 100%; max-width: 440px;
  background: var(--surface); border: 1px solid var(--line); backdrop-filter: blur(10px);
  border-radius: 20px; padding: 26px 24px 20px; box-shadow: 0 20px 60px rgba(0, 10, 30, 0.5);
  display: flex; flex-direction: column; gap: 14px; align-items: stretch; text-align: center;
}
.logo {
  font-family: var(--font-display); font-weight: 700; font-size: clamp(42px, 10vw, 60px); line-height: 1; margin: 0;
  color: var(--accent); text-shadow: 0 2px 0 #9a5a00, 0 8px 24px rgba(255, 176, 32, 0.35); letter-spacing: 0.01em;
  text-wrap: balance;
}
.tagline { margin: -6px 0 0; color: var(--muted); font-weight: 600; }

.skin-row { display: flex; align-items: center; gap: 8px; justify-content: center; }
.skin-box { position: relative; border-radius: 14px; overflow: hidden; border: 1px solid var(--line); flex: 1 1 auto; max-width: 260px; min-width: 0; }
.skin-box canvas { display: block; width: 100%; height: auto; max-width: 100%; }
.skin-name {
  position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%);
  background: rgba(3, 18, 36, 0.7); border-radius: 999px; padding: 2px 10px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
}
.arrow {
  width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface-2);
  font-size: 26px; line-height: 1; padding: 0 0 3px; flex: 0 0 auto;
}
.arrow:hover { background: rgba(79, 216, 255, 0.15); }

.field { display: flex; flex-direction: column; gap: 6px; text-align: left; }
.field-label { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
#fish-nick {
  font: inherit; font-weight: 700; font-size: 16px; color: var(--fg);
  background: rgba(3, 18, 36, 0.55); border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; width: 100%; box-sizing: border-box;
}
#fish-nick::placeholder { color: rgba(143, 179, 204, 0.6); font-weight: 600; }
#fish-nick:-webkit-autofill { -webkit-text-fill-color: var(--fg); box-shadow: 0 0 0 1000px #0a2238 inset; }
.name-row { display: flex; gap: 8px; align-items: stretch; }
.name-row #fish-nick { flex: 1 1 auto; min-width: 0; }
.shuffle {
  flex: 0 0 auto; width: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface-2);
  font-size: 20px; line-height: 1; padding: 0;
}
.shuffle:hover { background: rgba(79, 216, 255, 0.15); }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; }
.btn {
  flex: 1 1 140px; border-radius: 14px; padding: 12px 16px; font-weight: 800; font-size: 16px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--fg); transition: transform .08s, background .15s;
}
.btn:hover:not(:disabled) { background: rgba(79, 216, 255, 0.15); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-family: var(--font-display); font-size: 18px; letter-spacing: .02em; }
.btn.primary:hover:not(:disabled) { background: #ffc24a; }
/* 보상형 광고 '이어하기' */
.btn.reward {
  flex: 0 0 auto; width: 100%; display: flex; flex-direction: column; gap: 2px; align-items: center; padding: 10px 16px;
  background: linear-gradient(180deg, rgba(255, 176, 32, 0.22), rgba(255, 176, 32, 0.10)); border-color: var(--accent); color: var(--fg);
}
.btn.reward:hover:not(:disabled) { background: rgba(255, 176, 32, 0.3); }
.reward-k { font-family: var(--font-display); font-size: 17px; font-weight: 700; color: var(--accent); }
.reward-v { font-size: 12px; font-weight: 700; color: var(--muted); }

/* ---------- Info (start screen, below the fold) ---------- */
.info { width: 100%; max-width: 680px; margin-top: 28px; display: flex; flex-direction: column; gap: 14px; text-align: left; }
.info-block {
  background: rgba(6, 30, 56, 0.6); border: 1px solid var(--line); border-radius: 18px; padding: 20px 22px;
  color: var(--muted); font-size: 15px; line-height: 1.6;
}
.info-block h2 { font-family: var(--font-display); font-weight: 600; font-size: 22px; color: var(--fg); margin: 0 0 10px; line-height: 1.25; }
.info-block h3 { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: var(--cyan); margin: 0 0 6px; }
.info-block p { margin: 0 0 10px; }
.info-block p:last-child { margin-bottom: 0; }
.info-block b { color: var(--fg); }
.info-block a { color: var(--cyan); }
.info-block ol, .info-block ul { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.ctl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.ctl-grid ul { gap: 4px; }
.info-block details { border-top: 1px solid var(--line); padding: 10px 0; }
.info-block details:last-of-type { padding-bottom: 0; }
.info-block summary { cursor: pointer; font-weight: 800; color: var(--fg); list-style: none; display: flex; justify-content: space-between; gap: 12px; }
.info-block summary::-webkit-details-marker { display: none; }
.info-block summary::after { content: '+'; color: var(--cyan); font-weight: 700; flex: none; }
.info-block details[open] summary::after { content: '–'; }
.info-block details p { margin: 8px 0 0; }
.info-foot { margin: 4px 0 8px; font-size: 12px; color: var(--muted); text-align: center; }
.info-foot a { color: var(--muted); }
@media (max-width: 520px) { .info-block { padding: 16px; font-size: 14px; } }

/* 광고 자리 (카드 아래). slot 이 없으면 [hidden] 으로 숨겨짐 */
.ad-slot { width: 100%; max-width: 440px; min-height: 90px; display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.ad-slot .adsbygoogle { width: 100%; }

.note { margin: -4px 0 0; font-size: 12.5px; color: var(--muted); }
.note code { color: var(--cyan); font-size: 12px; }
.status { margin: -4px 0 0; font-size: 13px; color: var(--cyan); font-weight: 700; }

.controls { display: flex; gap: 8px; flex-wrap: wrap; }
.ctrl {
  flex: 1 1 150px; display: flex; flex-direction: column; gap: 2px; align-items: center; justify-content: center;
  background: rgba(3, 18, 36, 0.5); border: 1px solid var(--line); border-radius: 12px; padding: 8px 10px; min-width: 0;
}
.ctrl-k { font-family: var(--font-display); font-weight: 600; font-size: 15px; color: var(--accent); text-align: center; }
.ctrl-v { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.rules { margin: 2px 0 0; padding: 12px 14px; text-align: left; list-style: none; display: flex; flex-direction: column; gap: 6px;
  font-size: 13px; color: var(--muted); border-top: 1px solid var(--line); }
.rules b { color: var(--fg); }
.foot { margin: 0; font-size: 12px; color: var(--muted); }
.foot-link { color: var(--muted); text-decoration: underline dotted; }
.foot-link:hover { color: var(--fg); }
.muted { opacity: .7; }

.death-card h2 { font-family: var(--font-display); font-size: 44px; margin: 0; color: var(--danger); line-height: 1; }
.death-card .sub { margin: -4px 0 0; color: var(--muted); font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.stats > div { background: rgba(3, 18, 36, 0.5); border: 1px solid var(--line); border-radius: 12px; padding: 10px; display: flex; flex-direction: column; gap: 2px; }
.stats .val { font-family: var(--font-display); font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------- Toast ---------- */
#toast {
  position: absolute; left: 50%; bottom: calc(64px + var(--sa-b)); transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--line); color: var(--fg); border-radius: 12px; padding: 10px 16px;
  max-width: min(92vw, 520px); font-size: 14px; font-weight: 600; z-index: 20; text-align: center;
}
#toast.err { border-color: var(--danger); color: #ffd7d7; }

@media (max-width: 520px) {
  .card { padding: 20px 16px 16px; }
}
