/* ============================================================
   海洋糕手 · 海上大乱斗（横版）样式
   ============================================================ */
:root {
  --ink: #0A1E38;
  --card: rgba(255,255,255,.95);
  --lemon: #FFD43B;
  --coral: #FF6B81;
  --mint: #2ED8A3;
  --violet: #7C5CFC;
  --sun: #FFB648;
  --teal: #19B99B;
}
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  background: #081A30; color: #fff;
  user-select: none; -webkit-user-select: none; touch-action: none;
}
button { font-family: inherit; border: none; background: none; color: inherit; cursor: pointer; }
.layer { position: fixed; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; }

/* ---------- 旋转提示 ---------- */
.rotate-tip {
  position: fixed; inset: 0; z-index: 100; display: none;
  align-items: center; justify-content: center; flex-direction: column; gap: 16px;
  background: linear-gradient(180deg, #0B3460, #081A30);
  text-align: center;
}
.rt-icon { font-size: 60px; animation: rtSpin 2.2s ease-in-out infinite; }
@keyframes rtSpin { 0%,100% { transform: rotate(0);} 50% { transform: rotate(90deg);} }
.rt-text { font-size: 15px; letter-spacing: 2px; color: rgba(255,255,255,.85); font-weight: 700; line-height: 1.8; }
@media (orientation: portrait) { .rotate-tip { display: flex; } }
@media (orientation: landscape) { .rotate-tip { display: none; } }

/* ---------- 加载层 ---------- */
#loadLayer { z-index: 90; background: linear-gradient(180deg, #0B3460, #081A30); flex-direction: column; }
.load-logo { font-size: 58px; animation: bob 1.6s ease-in-out infinite; }
@keyframes bob { 0%,100% { transform: translateY(0);} 50% { transform: translateY(-10px);} }
.load-bar { width: 240px; height: 10px; margin-top: 26px; border-radius: 10px; background: rgba(255,255,255,.14); overflow: hidden; }
.load-fill { height: 100%; width: 0; border-radius: 10px; background: linear-gradient(90deg, #2ED8A3, #19B99B); transition: width .3s ease; }
.load-text { margin-top: 14px; font-size: 14px; letter-spacing: 3px; color: #2ED8A3; font-weight: 800; }

/* ---------- 启动页 ---------- */
#menuLayer { z-index: 30; }
.menu-bg {
  position: absolute; inset: 0;
  background:
    radial-gradient(700px 360px at 82% 8%, rgba(255,212,59,.2), transparent 60%),
    radial-gradient(560px 340px at 6% 94%, rgba(46,216,163,.16), transparent 60%),
    linear-gradient(180deg, #0B3460 0%, #0A2A4E 55%, #071E38 100%);
  overflow: hidden;
}
.menu-bg::before, .menu-bg::after {
  content: "🌊"; position: absolute; font-size: 80px; opacity: .14;
  animation: waveFloat 7s ease-in-out infinite;
}
.menu-bg::before { left: 6%; bottom: 10%; animation-delay: 1s; }
.menu-bg::after { right: 4%; bottom: 2%; font-size: 110px; animation-delay: 3s; }
@keyframes waveFloat { 0%,100% { transform: translateY(0) rotate(-6deg);} 50% { transform: translateY(-16px) rotate(6deg);} }

.menu-box { position: relative; width: 100%; max-width: 480px; padding: 18px 22px; text-align: center; max-height: 94vh; overflow-y: auto; }
.logo-icon {
  width: 74px; height: 74px; margin: 0 auto 8px; border-radius: 22px;
  display: grid; place-items: center; font-size: 38px;
  background: linear-gradient(135deg, #FF6B81, #FFB648);
  box-shadow: 0 14px 34px rgba(255,107,129,.35), inset 0 -6px 14px rgba(0,0,0,.12);
  animation: bob 3s ease-in-out infinite;
}
.logo h1 {
  font-size: 30px; font-weight: 900; letter-spacing: 5px;
  background: linear-gradient(120deg, #FFD43B, #FF6B81 55%, #7C5CFC);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.logo-sub { margin-top: 1px; font-size: 12px; letter-spacing: 7px; color: rgba(255,255,255,.7); font-weight: 700; }
.menu-tags { margin-top: 10px; display: flex; justify-content: center; gap: 7px; flex-wrap: wrap; }
.menu-tags span {
  font-size: 11px; font-weight: 700; letter-spacing: 1px; padding: 4px 11px; border-radius: 999px;
  background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.18);
}
.menu-btns { margin-top: 14px; display: flex; gap: 10px; }
.menu-btns .btn-main, .menu-btns .btn-ghost { flex: 1; }
.btn-main {
  width: 100%; padding: 13px 0; border-radius: 16px;
  font-size: 15px; font-weight: 800; letter-spacing: 2px; color: #5A3A00;
  background: linear-gradient(135deg, #FFD43B, #FFB648);
  box-shadow: 0 9px 24px rgba(255,182,72,.38);
  transition: transform .15s ease;
}
.btn-main:active { transform: scale(.96); }
.btn-ghost {
  width: 100%; padding: 12px 0; border-radius: 16px;
  font-size: 13.5px; font-weight: 700; letter-spacing: 2px; color: rgba(255,255,255,.85);
  background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.22);
}
.menu-rank { margin-top: 12px; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.13); border-radius: 16px; padding: 10px 13px 8px; text-align: left; }
.rank-title { font-size: 12px; font-weight: 800; letter-spacing: 2px; }
.rank-list { margin-top: 6px; display: flex; flex-direction: column; gap: 4px; }
.rank-row { display: flex; align-items: center; gap: 9px; font-size: 12px; padding: 3px 8px; border-radius: 9px; background: rgba(255,255,255,.05); }
.rank-row .rk { width: 20px; text-align: center; font-weight: 900; color: var(--lemon); }
.rank-row .rname { flex: 1; font-weight: 700; }
.rank-row .rkill { color: var(--coral); font-weight: 800; }
.rank-empty { font-size: 11.5px; color: rgba(255,255,255,.5); text-align: center; padding: 6px 0; }
.menu-warn { margin-top: 10px; font-size: 10px; line-height: 1.7; color: rgba(255,255,255,.45); }
.menu-age {
  position: absolute; top: 12px; right: 12px;
  width: 40px; height: 46px; border-radius: 8px;
  border: 2px solid #2ED8A3; color: #2ED8A3;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 900; letter-spacing: 1px; line-height: 1.1;
  background: rgba(46,216,163,.08);
}
.menu-foot { margin-top: 10px; font-size: 10px; color: rgba(255,255,255,.45); letter-spacing: 1px; }

/* ---------- 玩法介绍 ---------- */
#howLayer { z-index: 40; background: rgba(4,16,30,.84); backdrop-filter: blur(10px); }
.how-box { width: 100%; max-width: 560px; padding: 20px 22px; }
.how-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.how-head h2 { font-size: 20px; font-weight: 900; letter-spacing: 3px; }
.how-page { font-size: 12px; font-weight: 800; color: rgba(255,255,255,.6); }
.how-stage {
  min-height: 300px; border-radius: 18px; position: relative; overflow: hidden;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.14);
  display: flex; align-items: center; justify-content: center;
}
.how-stage .hs-canvas { position: relative; width: 100%; height: 300px; }
.how-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.how-stage .hs-cap { position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%); font-size: 13px; font-weight: 700; letter-spacing: 1px; background: rgba(4,16,30,.72); padding: 6px 16px; border-radius: 999px; white-space: nowrap; }
.how-dots { display: flex; justify-content: center; gap: 7px; margin-top: 12px; }
.how-dots i { width: 8px; height: 8px; border-radius: 50%; background: rgba(255,255,255,.28); transition: all .3s ease; }
.how-dots i.on { width: 22px; border-radius: 6px; background: var(--mint); }
.how-nav { display: flex; gap: 10px; margin-top: 12px; }
.how-nav .btn-main, .how-nav .btn-ghost { flex: 1; }

/* ---------- 游戏层（横版） ---------- */
#gameLayer { z-index: 20; display: none; background: #081A30; }
#gameLayer.show { display: block; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.hud { position: absolute; top: 0; left: 0; right: 0; padding: calc(8px + env(safe-area-inset-top)) 12px 0; pointer-events: none; z-index: 5; }
.hud-top { display: flex; align-items: flex-start; justify-content: space-between; }
.hud-left { display: flex; gap: 6px; }
.hud-coin, .hud-item, .hud-kill {
  display: flex; align-items: center; gap: 4px;
  background: rgba(6,24,44,.6); backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 11px; padding: 4px 10px; font-size: 13px; font-weight: 800;
}
.sound-btn {
  pointer-events: auto; width: 30px; height: 30px; margin-left: 6px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(6,24,44,.6); backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,.16); border-radius: 11px;
  font-size: 13px; color: #fff; cursor: pointer;
}
.sound-btn.muted { opacity: .6; }
.hud-wood span { color: #FFB648; }
.hud-kill { color: var(--coral); }
.hud-cycle { text-align: center; margin-top: 2px; }
.cycle-tag {
  display: inline-block; font-size: 11.5px; font-weight: 800; letter-spacing: 1px;
  padding: 3px 11px; border-radius: 999px;
  background: linear-gradient(135deg, #FFD43B, #FFB648); color: #5A3A00;
}
.cycle-tag.night { background: linear-gradient(135deg, #7C5CFC, #4E8DF8); color: #fff; }
.cycle-num { margin-top: 2px; font-size: 12px; font-weight: 800; color: rgba(255,255,255,.9); letter-spacing: 1px; }
.hud-task {
  margin-top: 7px; width: 232px; padding: 7px 11px; border-radius: 12px;
  background: rgba(6,24,44,.6); backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,.16);
  position: relative; padding-right: 46px;
}
.task-tag { font-size: 10px; font-weight: 800; letter-spacing: 2px; color: var(--lemon); }
.task-name { font-size: 12.5px; font-weight: 700; margin-top: 1px; }
.task-prog { height: 5px; margin-top: 4px; border-radius: 5px; background: rgba(255,255,255,.16); overflow: hidden; }
.task-fill { height: 100%; width: 0; border-radius: 5px; background: linear-gradient(90deg, #2ED8A3, #19B99B); transition: width .3s ease; }
.task-num { position: absolute; right: 11px; top: 50%; transform: translateY(-50%); font-size: 11px; font-weight: 800; color: rgba(255,255,255,.75); }

.joystick { position: absolute; left: 18px; bottom: calc(16px + env(safe-area-inset-bottom)); z-index: 6; }
.joy-base {
  width: 108px; height: 108px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.15) 0%, rgba(255,255,255,.05) 70%);
  border: 2px solid rgba(255,255,255,.28);
  box-shadow: 0 8px 26px rgba(0,0,0,.3), inset 0 0 26px rgba(255,255,255,.05);
}
.joy-knob {
  position: absolute; left: 50%; top: 50%; width: 50px; height: 50px; margin: -25px 0 0 -25px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #FFD43B, #FF9A3C);
  box-shadow: 0 6px 16px rgba(255,170,60,.5), inset 0 -4px 10px rgba(0,0,0,.15);
  transition: transform .06s linear;
}
.sprint-btn {
  position: absolute; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 6;
  width: 92px; height: 82px; border-radius: 22px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  background: linear-gradient(145deg, rgba(46,216,163,.92), rgba(25,185,155,.92));
  box-shadow: 0 10px 26px rgba(25,185,155,.45), inset 0 -5px 12px rgba(0,0,0,.16);
  border: 2px solid rgba(255,255,255,.35);
}
.sprint-btn:active { transform: scale(.94); }
.sp-ico { font-size: 24px; }
.sp-label { font-size: 11px; font-weight: 800; letter-spacing: 2px; }
.sp-bar { width: 62px; height: 5px; margin-top: 3px; border-radius: 5px; background: rgba(0,0,0,.25); overflow: hidden; }
.sp-fill { height: 100%; width: 100%; border-radius: 5px; background: #fff; }
.sprint-btn.low .sp-fill { background: #FFD43B; }

.tip-pop {
  position: absolute; left: 50%; bottom: 26%; transform: translateX(-50%);
  padding: 8px 18px; border-radius: 999px; z-index: 7;
  background: rgba(6,24,44,.72); backdrop-filter: blur(6px);
  border: 1px solid rgba(255,255,255,.18);
  font-size: 12.5px; font-weight: 700; letter-spacing: 1px;
  opacity: 0; transition: opacity .3s ease; white-space: nowrap;
}
.tip-pop.show { opacity: 1; }
.cycle-banner {
  position: absolute; top: 24%; left: 50%; transform: translateX(-50%) scale(.6);
  font-size: 24px; font-weight: 900; letter-spacing: 4px; z-index: 8;
  opacity: 0; pointer-events: none;
  text-shadow: 0 4px 20px rgba(0,0,0,.5);
}
.cycle-banner.show { animation: bannerIn 1.8s ease both; }
.cycle-banner.day { color: #FFD43B; }
.cycle-banner.night { color: #A78BFF; }
@keyframes bannerIn {
  0% { opacity: 0; transform: translateX(-50%) scale(.6); }
  18% { opacity: 1; transform: translateX(-50%) scale(1); }
  80% { opacity: 1; transform: translateX(-50%) scale(1); }
  100% { opacity: 0; transform: translateX(-50%) scale(1.1); }
}

/* ---------- 升级三选一 ---------- */
.upg-layer { z-index: 45; background: rgba(4,16,30,.66); backdrop-filter: blur(6px); }
.upg-box { width: 100%; max-width: 580px; padding: 18px 20px; }
.upg-head { text-align: center; }
.upg-title { font-size: 26px; font-weight: 900; letter-spacing: 2px; color: var(--lemon); text-shadow: 0 4px 16px rgba(255,212,59,.4); }
.upg-sub { margin-top: 4px; font-size: 12.5px; color: rgba(255,255,255,.75); letter-spacing: 1px; }
.upg-cards { margin-top: 14px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.upg-card {
  border-radius: 18px; padding: 16px 10px 14px; text-align: center; cursor: pointer;
  background: rgba(255,255,255,.07); border: 1.5px solid rgba(255,255,255,.16);
  transition: transform .15s ease, border-color .2s ease, background .2s ease;
}
.upg-card:active { transform: scale(.95); }
.upg-card:hover { border-color: var(--lemon); background: rgba(255,212,59,.12); }
.upg-card .uc-ico { font-size: 34px; }
.upg-card .uc-name { margin-top: 6px; font-size: 13.5px; font-weight: 800; }
.upg-card .uc-desc { margin-top: 3px; font-size: 11px; color: rgba(255,255,255,.6); line-height: 1.5; }
.upg-card .uc-lv { margin-top: 6px; display: inline-block; font-size: 10.5px; font-weight: 800; padding: 2px 9px; border-radius: 999px; background: rgba(255,255,255,.14); }
.upg-card .uc-lv.up { background: rgba(46,216,163,.2); color: #2ED8A3; }

/* ---------- 结算 ---------- */
#overLayer { z-index: 35; background: rgba(4,16,30,.78); backdrop-filter: blur(8px); }
.over-box { width: 100%; max-width: 460px; padding: 24px 22px; text-align: center; }
.over-box h2 { font-size: 24px; font-weight: 900; letter-spacing: 3px; }
.over-stats { margin-top: 16px; display: flex; justify-content: center; gap: 26px; }
.o-item .o-v { font-size: 28px; font-weight: 900; color: var(--lemon); }
.o-item .o-l { font-size: 11.5px; color: rgba(255,255,255,.6); letter-spacing: 1px; }
.over-rank-tip { margin-top: 12px; font-size: 12px; color: rgba(255,255,255,.7); }
.over-btns { margin-top: 18px; display: flex; gap: 10px; }
.over-btns .btn-main, .over-btns .btn-ghost { flex: 1; }

/* 竖屏时隐藏游戏层（旋转提示覆盖） */
@media (orientation: portrait) {
  #gameLayer, #hud { display: none !important; }
}
