/* Boat Shutter — layout & UI chrome. The game itself is drawn on <canvas>. */
:root {
  --bg: #071d28;
  --panel: #0e3346;
  --panel-2: #124258;
  --ink: #eaf6ff;
  --muted: #9fc2d4;
  --accent: #ffcc4d;
  --accent-2: #46d38b;
  --danger: #ff6b6b;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  user-select: none; -webkit-user-select: none; touch-action: none;
  overscroll-behavior: none;
}

#app {
  display: flex; flex-direction: column;
  height: 100dvh; width: 100vw;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}

/* ---------- Top HUD ---------- */
#hud {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px;
  background: linear-gradient(180deg, var(--panel), transparent);
}
.hud-item {
  font-weight: 700; font-size: clamp(14px, 4.2vw, 20px);
  background: rgba(0,0,0,0.25); padding: 6px 10px; border-radius: 12px;
  min-width: 64px; text-align: center;
}
.hud-btn {
  margin-left: auto;
  font-weight: 700; font-size: clamp(13px, 3.6vw, 17px);
  color: var(--ink); background: var(--panel-2);
  border: 1px solid rgba(255,255,255,0.12); border-radius: 12px;
  padding: 6px 12px; cursor: pointer;
}
.hud-btn:active { transform: scale(0.96); }

/* ---------- Stage ---------- */
#stage { position: relative; flex: 1 1 auto; min-height: 0; }
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* Centre banner */
#banner {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  background: rgba(2, 12, 18, 0.55); backdrop-filter: blur(3px); z-index: 5;
}
#banner.hidden { display: none; }
.banner-card {
  text-align: center; max-width: 86%; padding: 24px 26px;
  background: var(--panel); border: 1px solid rgba(255,255,255,0.14);
  border-radius: 20px; box-shadow: 0 18px 50px rgba(0,0,0,0.5);
}
.banner-card h1 { margin: 0 0 8px; font-size: clamp(24px, 7vw, 40px); }
.banner-card p { margin: 0 0 18px; color: var(--muted); font-size: clamp(14px, 4vw, 18px); line-height: 1.4; }

/* ---------- Shop ---------- */
#shop {
  flex: 0 0 auto;
  background: linear-gradient(0deg, var(--panel), transparent);
  padding: 8px 8px calc(8px + var(--safe-bottom));
  display: flex; flex-direction: column; gap: 8px;
}
#shop-scroll {
  display: flex; gap: clamp(3px, 1.3vw, 8px); padding: 4px 2px 8px; min-width: 0;
}
.turret-card {
  flex: 1 1 0; min-width: 0;                    /* rubber: shrink evenly to fit any width */
  padding: clamp(5px, 1.6vw, 9px) clamp(2px, 0.8vw, 6px);
  background: var(--panel-2); border: 2px solid transparent; border-radius: clamp(9px, 2.6vw, 14px);
  text-align: center; cursor: pointer; transition: transform .08s, border-color .12s;
}
.turret-card:active { transform: scale(0.96); }
.turret-card.selected { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(255,204,77,0.25) inset; }
.turret-card.locked { opacity: 0.45; }
.turret-card .emoji { font-size: clamp(17px, 6.2vw, 28px); line-height: 1; }
.turret-card .name { font-size: clamp(9px, 2.7vw, 12px); font-weight: 700; margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.turret-card .cost { font-size: clamp(10px, 3vw, 12px); color: var(--accent); margin-top: 2px; font-weight: 800; white-space: nowrap; }

#shop-actions { display: flex; gap: 6px; min-width: 0; align-items: stretch; }
#shop-actions .primary-btn { flex: 1 1 0; min-width: 0; padding: clamp(10px, 3vw, 12px) 6px; font-size: clamp(13px, 3.8vw, 19px); }
#shop-actions .ghost-btn { flex: 0 1 auto; min-width: 0; padding: clamp(9px, 2.4vw, 12px) clamp(7px, 2.2vw, 16px); font-size: clamp(12px, 3.2vw, 17px); white-space: nowrap; }
.primary-btn {
  flex: 1; padding: 12px; font-size: clamp(15px, 4.4vw, 19px); font-weight: 800;
  color: #07202b; background: linear-gradient(180deg, #7ff0b6, var(--accent-2));
  border: none; border-radius: 14px; cursor: pointer;
}
.primary-btn:disabled { filter: grayscale(0.6) brightness(0.8); cursor: default; }
.primary-btn:active:not(:disabled) { transform: scale(0.98); }
.ghost-btn {
  padding: 12px 16px; font-size: clamp(14px, 4vw, 17px); font-weight: 700;
  color: var(--ink); background: transparent;
  border: 1px solid rgba(255,255,255,0.22); border-radius: 14px; cursor: pointer;
}
.ghost-btn.active { border-color: var(--danger); color: var(--danger); }

/* ---------- Welcome / login screen ---------- */
#welcome {
  position: fixed; inset: 0; z-index: 20; overflow: hidden;
  display: flex; align-items: stretch; justify-content: center;
}
#welcome.hidden { display: none; }
#welcome-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.welcome-scrim {
  position: absolute; inset: 0;
  background: radial-gradient(120% 80% at 50% 8%, transparent 30%, rgba(4,10,16,0.55) 100%);
}
.welcome-content {
  position: relative; z-index: 1; width: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between;
  padding: calc(20px + var(--safe-top)) 18px calc(18px + var(--safe-bottom));
  overflow-y: auto;
}
.welcome-hero { text-align: center; margin-top: 6vh; text-shadow: 0 3px 18px rgba(0,0,0,0.55); }
.welcome-title { margin: 0; font-size: clamp(34px, 10vw, 68px); font-weight: 900; letter-spacing: 0.5px; color: #fff; }
.welcome-tag { margin: 6px 0 0; font-size: clamp(14px, 4.2vw, 20px); color: #ffe6c7; font-weight: 600; }

.welcome-panel {
  width: min(440px, 94vw); margin-top: auto;
  background: rgba(7, 18, 28, 0.72); backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,0.12); border-radius: 20px;
  padding: 16px; box-shadow: 0 18px 50px rgba(0,0,0,0.5);
  display: flex; flex-direction: column; gap: 14px;
}

/* branded LinArt button (canonical style — do not restyle) */
.linart-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; width: 100%;
  background: #0b1220; color: #f8fafc; border: none; border-radius: 10px; padding: 13px 16px;
  font: 700 16px/1 Inter, 'Segoe UI', Arial, sans-serif; cursor: pointer; transition: filter .15s;
}
.linart-btn:hover { filter: brightness(1.18); }
.linart-btn:active { transform: scale(0.99); }
.auth-note { text-align: center; font-size: 12.5px; color: var(--muted); margin-top: 8px; }
.auth-note span { opacity: 0.8; }

.signed { display: flex; flex-direction: column; gap: 8px; }
.signed-row { font-size: 14px; color: var(--ink); }
.signed-row b { color: var(--accent); }
.name-label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); }
.name-label input {
  padding: 10px 12px; font-size: 15px; color: var(--ink);
  background: rgba(0,0,0,0.3); border: 1px solid rgba(255,255,255,0.16); border-radius: 10px;
}
.signed-actions { display: flex; gap: 8px; }
.signed-actions .ghost-btn { flex: 1; }

.board { display: flex; flex-direction: column; gap: 8px; }
.board-title { font-weight: 800; font-size: 15px; color: var(--ink); }
#board-list { list-style: none; margin: 0; padding: 0; max-height: 34vh; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }
.board-empty { color: var(--muted); font-size: 13px; text-align: center; padding: 10px; }
.board-row { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 8px;
  padding: 7px 10px; background: rgba(255,255,255,0.04); border-radius: 10px; font-size: 14px; }
.board-row.me { background: rgba(255,204,77,0.16); outline: 1px solid rgba(255,204,77,0.4); }
.board-row .rk { font-weight: 800; color: var(--accent); text-align: center; }
.board-row .nm { font-weight: 600; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-row .sc { color: var(--muted); font-size: 12.5px; font-weight: 700; }
.welcome-play { width: 100%; font-size: clamp(17px, 5vw, 22px); padding: 14px; }

/* small toast */
#toast {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
  background: rgba(0,0,0,0.7); color: #fff; padding: 8px 14px; border-radius: 999px;
  font-size: 14px; font-weight: 600; opacity: 0; transition: opacity .25s; pointer-events: none; z-index: 8;
}
#toast.show { opacity: 1; }
