:root {
  color-scheme: light;
  --ink: #172026;
  --muted: #66717a;
  --paper: #fff8e8;
  --panel: #ffffff;
  --line: #e3d7bd;
  --accent: #0f8b8d;
  --sea: #0f8b8d;
  --complete: #22a447;
  --gold: #f4b942;
  --danger: #d62828;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: linear-gradient(180deg, #fff4d5 0%, #e9fbff 48%, #f8efe1 100%);
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app {
  width: min(100%, 820px);
  margin: 0 auto;
  padding: 14px 12px 28px;
}

.topbar, .team-panel, .score-strip, .letter-strip, .tabs, .view, .dialog-card, .marina-section {
  border: 1px solid var(--line);
  background: rgba(255,255,255,.9);
  box-shadow: 0 12px 28px rgba(52, 38, 10, .08);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 8px;
  padding: 12px 14px;
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--sea);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1, h2 { margin: 0; letter-spacing: 0; }
h1 { font-size: clamp(25px, 7vw, 42px); line-height: 1; }
h2 { font-size: 24px; }

.icon-btn, .close {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  font-size: 24px;
}

.team-panel {
  display: block;
  margin-top: 10px;
  padding: 10px;
  border-radius: 8px;
}

.login-form {
  display: grid;
  gap: 10px;
}

.team-session {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.team-session[hidden],
.login-form[hidden] {
  display: none;
}

.team-session span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 850;
}

.team-session strong {
  color: var(--ink);
}

.team-session .secondary {
  width: auto;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

input, select, textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 11px;
  background: #fff;
  color: var(--ink);
}

.score-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 8px;
}

.score-strip div {
  display: grid;
  place-items: center;
  padding: 10px 4px;
  background: #fff;
}

.score-strip strong { font-size: 22px; line-height: 1; }
.score-strip span { color: var(--muted); font-size: 11px; font-weight: 800; text-transform: uppercase; }

.letter-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 10px;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
}

.letter-strip span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.letter-strip strong {
  color: #7d5220;
  font-size: 18px;
  letter-spacing: 0;
  white-space: nowrap;
}

.unlock-banner {
  margin-top: 10px;
}

.unlock-banner[hidden] { display: none; }

.unlock-card {
  display: grid;
  grid-template-columns: 74px 1fr;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 86px;
  border: 2px solid rgba(214, 40, 40, .58);
  border-radius: 8px;
  padding: 8px;
  background: #fff1ef;
  color: var(--ink);
  text-align: left;
  box-shadow: 0 14px 30px rgba(214, 40, 40, .12);
}

.unlock-card img {
  width: 74px;
  height: 64px;
  border-radius: 6px;
  object-fit: cover;
}

.unlock-card span {
  display: grid;
  gap: 4px;
}

.unlock-card strong {
  font-size: 15px;
  line-height: 1.15;
}

.unlock-card small {
  color: var(--muted);
  font-weight: 750;
}

.map-wrap {
  position: relative;
  margin-top: 10px;
  overflow: hidden;
  border-radius: 8px;
  border: 2px solid #7d5220;
  background: #f7cf70;
}

.map-wrap img {
  display: block;
  width: 100%;
  aspect-ratio: 1280 / 831;
  object-fit: cover;
}

.marina-section {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  padding: 10px;
  border-radius: 8px;
}

.marina-section[hidden] { display: none; }

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.section-title h2 { font-size: 22px; }

.marina-map { margin-top: 0; border-color: var(--sea); }

.marina-map img {
  aspect-ratio: 1280 / 744;
  object-fit: cover;
}

.marina-tasks {
  display: grid;
  gap: 10px;
  margin-top: 10px;
}

.marina-pin {
  background: var(--sea);
}

.marina-lock {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.marina-lock[hidden],
#marinaContent[hidden] {
  display: none;
}

.marina-lock p {
  margin: 0;
  color: var(--ink);
  line-height: 1.35;
}

.marina-password {
  display: grid;
  gap: 10px;
}

.error {
  min-height: 18px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 850;
}

.pin {
  position: absolute;
  left: var(--x);
  top: var(--y);
  transform: translate(-50%, -50%);
  width: 34px;
  height: 34px;
  border: 3px solid #fff;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 900;
  box-shadow: 0 5px 14px rgba(0,0,0,.28);
}

.pin.done { background: var(--complete); }
.pin.pending { background: var(--gold); color: #3a2707; }

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-top: 10px;
  padding: 4px;
  border-radius: 8px;
}

.tab {
  min-height: 40px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font-weight: 850;
}
.tab.active { background: var(--ink); color: #fff; }

.view {
  display: none;
  margin-top: 10px;
  border-radius: 8px;
  padding: 10px;
}
.view.active { display: grid; gap: 10px; }

.quest {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 64px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.quest.done {
  border-color: rgba(34, 164, 71, .45);
  background: #f0fff4;
}

.quest.done .badge,
.quest.done button {
  background: var(--complete);
  color: #fff;
}

.quest.done p {
  color: #167135;
  font-weight: 800;
}

.quest.pending {
  border-color: rgba(244, 185, 66, .72);
  background: #fff8df;
}

.quest.pending .badge,
.quest.pending button {
  background: var(--gold);
  color: #3a2707;
}

.quest.pending p {
  color: #7d5220;
  font-weight: 800;
}

.quest.unlocked-shanty {
  border-color: rgba(214, 40, 40, .48);
  background: #fff1ef;
}

.quest.unlocked-shanty .badge,
.quest.unlocked-shanty button {
  background: var(--danger);
  color: #fff;
}

.quest.unlocked-shanty.done {
  border-color: rgba(34, 164, 71, .45);
  background: #f0fff4;
}

.quest.locked {
  opacity: .72;
  background: #f7f2e8;
}

.quest.locked .badge {
  background: #e8dfcd;
}

.badge {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--paper);
  font-weight: 900;
}

.quest h3, .quest p { margin: 0; }
.quest h3 { font-size: 15px; }
.quest p { color: var(--muted); font-size: 13px; }

.quest button, .primary, .secondary, .voice-btn {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  padding: 0 12px;
  background: var(--accent);
  color: #fff;
  font-weight: 900;
}

.secondary {
  width: 100%;
  background: var(--sea);
}

.danger {
  background: var(--danger);
}

.voice-btn {
  width: 100%;
  background: #7d5220;
}

.song-panel {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.song-panel[hidden] { display: none; }
.song-panel audio { width: 100%; display: block; }

.proof-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.proof-card { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.proof-card img,
.proof-card video { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: #111; }
.proof-card div { padding: 8px; font-size: 12px; font-weight: 800; }

.empty { color: var(--muted); margin: 0; padding: 16px 4px; text-align: center; }

.leader {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 8px;
  background: #fff;
  border: 1px solid var(--line);
}

.admin-panel,
.admin-card {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.admin-panel h2,
.admin-panel p,
.admin-card h3,
.admin-card p {
  margin: 0;
}

.admin-panel p,
.admin-card p,
.admin-card small {
  color: var(--muted);
}

.admin-card {
  grid-template-columns: 1fr auto;
  align-items: center;
}

.admin-actions {
  display: flex;
  gap: 8px;
}

.admin-review-card {
  align-items: start;
}

.admin-review-main {
  display: grid;
  gap: 8px;
}

.admin-proof {
  width: min(100%, 260px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--muted);
}

.proof-preview {
  display: block;
  padding: 0;
  overflow: hidden;
  cursor: zoom-in;
}

.proof-preview img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  display: block;
}

.video-proof,
.empty-proof {
  padding: 10px;
  font-size: 12px;
  font-weight: 800;
}

.approved-list {
  background: #f0fff4;
  border-color: rgba(34, 164, 71, .35);
}

.game-master-proof {
  gap: 12px;
}

.game-master-proof-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
}

.game-master-proof-card {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
}

.game-master-proof-card .admin-proof {
  width: 100%;
}

.game-master-proof-card strong,
.game-master-proof-card span,
.game-master-proof-card small {
  display: block;
}

.game-master-proof-card span {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.game-master-proof-card small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.team-create {
  gap: 10px;
}

.team-list {
  gap: 8px;
}

.team-list strong {
  color: var(--ink);
}

dialog {
  width: min(calc(100% - 24px), 520px);
  border: 0;
  padding: 0;
  background: transparent;
}
dialog::backdrop { background: rgba(14, 22, 28, .55); }

.dialog-card {
  display: grid;
  gap: 12px;
  border-radius: 8px;
  padding: 16px;
}
.close { justify-self: end; margin-bottom: -12px; }
.dialog-card p { margin: 0; color: var(--muted); }
.dialog-letter {
  width: fit-content;
  border-radius: 8px;
  padding: 8px 10px;
  background: #f0fff4;
  color: #167135;
  border: 1px solid rgba(34, 164, 71, .35);
}

.dialog-letter[hidden] { display: none; }
.dialog-image {
  width: 100%;
  max-height: 240px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid var(--line);
}
.dialog-image[hidden] { display: none; }
.proof-upload { padding: 12px; border: 1px dashed var(--line); border-radius: 8px; background: var(--paper); }

@media (max-width: 560px) {
  .app { padding: 10px 8px 22px; }
  .quest { grid-template-columns: 38px 1fr; }
  .quest button { grid-column: 1 / -1; }
  .pin { width: 30px; height: 30px; font-size: 13px; }
  .section-title h2 { font-size: 20px; }
  .tabs { grid-template-columns: repeat(2, 1fr); }
  .admin-card { grid-template-columns: 1fr; }
  .admin-actions { display: grid; grid-template-columns: 1fr 1fr; }
}
