*,
*::before,
*::after { box-sizing: border-box; }

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(120% 70% at 100% -10%, rgba(247, 13, 26, 0.28), transparent 46%),
    radial-gradient(80% 50% at -10% 10%, rgba(0, 88, 109, 0.45), transparent 52%),
    #112233;
  color: #e7d6af;
  font-family: Roboto, "Noto Sans", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
}

button,
img { -webkit-tap-highlight-color: transparent; }

button {
  font: inherit;
  cursor: pointer;
}

img {
  max-width: 100%;
  -webkit-user-drag: none;
}

[hidden] { display: none !important; }

.app {
  width: min(100%, 520px);
  height: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(17, 34, 51, 0.2), #112233 28%);
  color: #e7d6af;
  user-select: none;
}

.mast {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  padding: calc(8px + env(safe-area-inset-top)) 10px 6px;
}

.mark {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(160deg, #f70d1a, #8d0812);
  border: 1px solid #fed340;
  box-shadow: 0 0 0 3px rgba(254, 211, 64, 0.16), inset 0 0 0 2px rgba(254, 211, 64, 0.35);
}

.mark b {
  color: #fed340;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.mast-copy { min-width: 0; }

.mast-copy p,
.kicker {
  margin: 0;
  color: #ffd266;
  font-size: 12px;
  line-height: 1.2;
}

.mast-copy h1 {
  margin: 1px 0 0;
  font-size: clamp(16px, 4.7vw, 22px);
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #fed340;
  font-weight: 800;
}

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid rgba(254, 211, 64, 0.7);
  background: #0d1b2a;
  color: #fed340;
  font-size: 12px;
  font-weight: 800;
}

.bank {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  color: #fed340;
  font-weight: 800;
}

.bank img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

.bulbs {
  grid-column: 1 / -1;
  display: flex;
  gap: 5px;
}

.bulbs i {
  flex: 1;
  height: 5px;
  border-radius: 99px;
  background: #fed340;
  opacity: 0.35;
  box-shadow: 0 0 6px rgba(254, 211, 64, 0.75);
  animation: bulb 1.6s ease-in-out infinite;
}

.bulbs i:nth-child(2n) { animation-delay: 0.15s; }
.bulbs i:nth-child(3n) { animation-delay: 0.3s; }
.bulbs i:nth-child(4n) { animation-delay: 0.45s; }
.bulbs i:nth-child(5n) { animation-delay: 0.6s; }

@keyframes bulb {
  0%, 100% { opacity: 0.28; }
  50% { opacity: 1; }
}

main {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.view { display: none; min-width: 0; min-height: 0; }

.view.scroll.is-active {
  display: block;
  overflow: auto;
  flex: 1 1 auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}

.view.scroll.is-active::-webkit-scrollbar { display: none; }

.view.play.is-active {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1 1 auto;
}

.pad {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px 12px 18px;
  min-width: 0;
}

.hero {
  position: relative;
  height: clamp(128px, 24vh, 210px);
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(254, 211, 64, 0.75);
  box-shadow: inset 0 0 0 1px rgba(247, 13, 26, 0.35);
}

.hero img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.hero-copy {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 16px 12px 10px;
  background: linear-gradient(transparent, rgba(8, 16, 28, 0.92));
}

.hero-copy p {
  margin: 0;
  color: #ffd266;
  font-size: 12px;
}

.hero-copy strong {
  display: block;
  margin-top: 2px;
  color: #fed340;
  font-size: clamp(20px, 6vw, 28px);
  line-height: 1.15;
}

.lead {
  margin: 0;
  font-size: 15px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.gold-btn,
.ghost-btn,
.text-btn {
  min-height: 46px;
  padding: 10px 12px;
  border-radius: 999px;
  font-weight: 800;
}

.gold-btn {
  border: 0;
  color: #112233;
  background-image: linear-gradient(110deg, #ea5505 0%, #ffb301 28%, #fff1b0 44%, #fed340 58%, #ea5505 100%);
  background-size: 220% 100%;
  animation: shine 4s linear infinite;
  box-shadow: 0 6px 0 #7a2a00;
}

.gold-btn:active {
  transform: translateY(2px);
  box-shadow: 0 3px 0 #7a2a00;
}

@keyframes shine {
  from { background-position: 0 0; }
  to { background-position: 220% 0; }
}

.ghost-btn {
  border: 1px solid #fed340;
  background: transparent;
  color: #fed340;
}

.text-btn {
  border: 0;
  background: transparent;
  color: #d8dee7;
}

.wide { width: 100%; }

button:disabled { opacity: 0.38; }

button:focus-visible {
  outline: 2px solid #fed340;
  outline-offset: 2px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.stat { text-align: center; padding: 10px 6px; }

.stat b {
  display: block;
  color: #fed340;
  font-size: clamp(18px, 5.4vw, 26px);
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}

.stat span {
  display: block;
  margin-top: 3px;
  color: #d8dee7;
  font-size: 12px;
  line-height: 1.2;
}

.framed,
.plaque {
  position: relative;
  border-radius: 16px;
  border: 1px solid rgba(254, 211, 64, 0.45);
  background:
    linear-gradient(#fed340, #fed340) left 8px top 8px / 16px 2px no-repeat,
    linear-gradient(#fed340, #fed340) left 8px top 8px / 2px 16px no-repeat,
    linear-gradient(#fed340, #fed340) right 8px top 8px / 16px 2px no-repeat,
    linear-gradient(#fed340, #fed340) right 8px top 8px / 2px 16px no-repeat,
    linear-gradient(#fed340, #fed340) left 8px bottom 8px / 16px 2px no-repeat,
    linear-gradient(#fed340, #fed340) left 8px bottom 8px / 2px 16px no-repeat,
    linear-gradient(#fed340, #fed340) right 8px bottom 8px / 16px 2px no-repeat,
    linear-gradient(#fed340, #fed340) right 8px bottom 8px / 2px 16px no-repeat,
    linear-gradient(180deg, rgba(254, 211, 64, 0.08), rgba(0, 0, 0, 0.22));
  box-shadow: inset 0 0 0 1px rgba(247, 13, 26, 0.28);
}

.plaque { padding: 12px; min-width: 0; }

.plaque h3,
.panel h2,
.sheet-card h2 {
  margin: 0 0 6px;
  color: #fed340;
  font-size: 20px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.plaque p,
.panel p,
.sheet-card p,
.guide p {
  margin: 0 0 8px;
  overflow-wrap: anywhere;
}

.muted { color: #d8dee7; font-size: 13px; }

.tide-row,
.vault-hero {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
}

.tide-mark {
  width: 12px;
  flex: 0 0 12px;
  align-self: stretch;
  min-height: 64px;
  border-radius: 99px;
  border: 1px solid rgba(254, 211, 64, 0.65);
  background: linear-gradient(#fed340, #00586d 55%, #112233);
}

.tide-copy,
.vault-hero div { min-width: 0; }

.tide-copy h2,
.vault-hero strong {
  display: block;
  margin: 0 0 4px;
  color: #fed340;
  font-size: 18px;
}

.vault-hero img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  flex: 0 0 auto;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.split {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.split > button { flex: 1 1 120px; min-width: 0; }

.is-locked { opacity: 0.62; }

.relic-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.relic h3 { font-size: 16px; }
.relic p { font-size: 13px; margin: 0; }

.record-list,
.end-list {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
}

.record-list li,
.end-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid rgba(254, 211, 64, 0.22);
  font-size: 14px;
}

.record-list li span,
.end-list li span { min-width: 0; }

.record-list b,
.end-list b {
  color: #fed340;
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}

.guide h2 {
  margin: 0 0 6px;
  color: #fed340;
  font-size: 18px;
}

.dock {
  flex: 0 0 auto;
  padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
}

.compass {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  align-items: end;
  gap: 2px;
  padding: 8px 4px 6px;
  border-radius: 18px 18px 14px 14px;
  border-top: 1px solid rgba(254, 211, 64, 0.75);
  border-bottom: 4px solid #f70d1a;
  background:
    linear-gradient(#6d1018, #6d1018) center / 100% 8px no-repeat,
    linear-gradient(180deg, #1b3044, #0c1824);
}

.nav-btn {
  min-width: 0;
  border: 0;
  background: transparent;
  color: #d8dee7;
  padding: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.seal {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(254, 211, 64, 0.55);
  background: radial-gradient(circle at 35% 30%, #2a4358, #0c1824 70%);
  display: grid;
  place-items: center;
  color: #fed340;
}

.seal svg { width: 18px; height: 18px; display: block; }

.nav-btn.helm .seal {
  width: 54px;
  height: 54px;
  border: 2px solid #fed340;
  background: radial-gradient(circle at 35% 30%, #7a1822, #1a0a0e 72%);
  overflow: hidden;
}

.nav-btn.helm .seal img {
  width: 78%;
  height: 78%;
  object-fit: contain;
}

.nav-label {
  display: block;
  max-width: 100%;
  margin-top: 4px;
  font-size: 11px;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-btn.is-on .nav-label { color: #fed340; }

.nav-btn.is-on .seal {
  box-shadow: 0 0 0 1px #fed340, 0 0 14px rgba(254, 211, 64, 0.45);
}

.sea {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  touch-action: none;
  overflow: hidden;
}

.sea canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hud {
  position: absolute;
  inset: 0;
  z-index: 2;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 8px;
}

.sea[data-phase="play"] .hud,
.sea[data-phase="pause"] .hud { opacity: 1; visibility: visible; }

.hud-top,
.hud-stats,
.hud-bottom {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  min-width: 0;
}

.hud-top { padding-right: 64px; }

.hud-top span,
.hud-stats span,
.chip {
  background: rgba(12, 24, 36, 0.78);
  border: 1px solid rgba(254, 211, 64, 0.35);
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 700;
  color: #e7d6af;
  max-width: 100%;
}

.grow {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#hudLane[data-lane="vang"] {
  color: #112233;
  background: #fed340;
  border-color: #fed340;
}

#hudLane[data-lane="son"] {
  color: #fff6e8;
  background: #f70d1a;
  border-color: #f70d1a;
}

.hud-bottom { align-items: flex-end; }

#oarBtn {
  margin-left: auto;
  pointer-events: none;
  border: 0;
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 999px;
  font-weight: 800;
  color: #112233;
  background: linear-gradient(180deg, #ffe58a, #ffb301);
  box-shadow: 0 4px 0 #7a2a00;
}

.sea[data-phase="play"] #oarBtn { pointer-events: auto; }

#pauseBtn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 4;
  visibility: hidden;
  pointer-events: none;
  min-height: 36px;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid #fed340;
  background: rgba(17, 34, 51, 0.88);
  color: #fed340;
  font-weight: 800;
}

.sea[data-phase="play"] #pauseBtn {
  visibility: visible;
  pointer-events: auto;
}

.tide {
  position: absolute;
  left: 8px;
  top: 78px;
  width: 58px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: none;
}

.tide-bar {
  width: 8px;
  height: 84px;
  border-radius: 99px;
  border: 1px solid rgba(254, 211, 64, 0.65);
  background: rgba(0, 0, 0, 0.28);
  display: flex;
  align-items: flex-end;
  overflow: hidden;
}

#tideFill {
  display: block;
  width: 100%;
  height: 40%;
  background: linear-gradient(#fed340, #00586d);
}

#tideLabel {
  width: 100%;
  font-size: 10px;
  line-height: 1.15;
  text-align: center;
  color: #e7d6af;
  overflow-wrap: anywhere;
}

.card-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  align-items: center;
  justify-items: center;
  padding: 10px;
  pointer-events: none;
}

.panel {
  width: min(100%, 440px);
  max-height: 100%;
  overflow: auto;
  pointer-events: auto;
  padding: 14px;
  scrollbar-width: none;
  background:
    linear-gradient(#fed340, #fed340) left 8px top 8px / 16px 2px no-repeat,
    linear-gradient(#fed340, #fed340) left 8px top 8px / 2px 16px no-repeat,
    linear-gradient(#fed340, #fed340) right 8px top 8px / 16px 2px no-repeat,
    linear-gradient(#fed340, #fed340) right 8px top 8px / 2px 16px no-repeat,
    linear-gradient(#fed340, #fed340) left 8px bottom 8px / 16px 2px no-repeat,
    linear-gradient(#fed340, #fed340) left 8px bottom 8px / 2px 16px no-repeat,
    linear-gradient(#fed340, #fed340) right 8px bottom 8px / 16px 2px no-repeat,
    linear-gradient(#fed340, #fed340) right 8px bottom 8px / 2px 16px no-repeat,
    #102033;
}

.panel::-webkit-scrollbar { display: none; }

.need {
  color: #fed340;
  font-weight: 700;
}

.legend { color: #ffd266; font-size: 14px; }

.flash {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at center, transparent 42%, rgba(247, 13, 26, 0.42));
  opacity: 0;
}

.sea.is-hurt .flash { opacity: 1; }

.toast {
  position: absolute;
  left: 12px;
  right: 12px;
  top: 74px;
  z-index: 5;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(12, 22, 34, 0.96);
  border: 1px solid rgba(254, 211, 64, 0.6);
  color: #e7d6af;
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.sheet {
  position: absolute;
  inset: 0;
  z-index: 6;
  background: rgba(6, 12, 18, 0.74);
  display: grid;
  align-items: end;
  padding: 12px;
}

.sheet-card {
  width: min(100%, 480px);
  margin: 0 auto;
  max-height: 78%;
  overflow: auto;
  padding: 14px;
}

.sheet-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

@media (max-width: 350px) {
  .pad { padding-inline: 10px; }
  .nav-label { font-size: 10px; }
  .mast { gap: 6px; }
  .mark { width: 42px; height: 42px; }
}

@media (max-height: 680px) {
  .hero { height: 112px; }
  .seal { width: 34px; height: 34px; }
  .nav-btn.helm .seal { width: 52px; height: 52px; }
  .tide { top: 70px; }
  .tide-bar { height: 64px; }
  .panel { padding: 10px; }
  .panel h2 { font-size: 18px; margin-bottom: 4px; }
  .panel p, .legend { font-size: 13px; margin-bottom: 6px; }
  .gold-btn, .ghost-btn, .text-btn { min-height: 40px; padding-block: 8px; }
  .stack { gap: 6px; }
}

@media (min-width: 400px) {
  .relic-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .pad { padding-inline: 16px; }
}

@media (min-width: 480px) {
  .hero { height: 200px; }
}

@media (prefers-reduced-motion: reduce) {
  .bulbs i,
  .gold-btn { animation: none; }
}
