/* ═══════════════════════════════════════════════════════════════
   NJORDFEL FUTURES — Viking Battleship CSS
   ═══════════════════════════════════════════════════════════════ */

/* ─── CSS Variables ─────────────────────────────────────────── */
:root {
  --gold:        #c9a84c;
  --gold-light:  #e8c87a;
  --gold-dark:   #8a6a1f;
  --dark-wood:   #3d2b1f;
  --deep-water:  #0a1628;
  --mid-water:   #122244;
  --light-water: #1a3a6c;
  --hit:         #e84b1a;
  --hit-light:   #ff6a3d;
  --miss:        #4a6fa5;
  --miss-light:  #6a8fc5;
  --ship-color:  #5c3d1e;
  --ship-light:  #7a5530;
  --grid-line:   #1a3a5c;
  --text-primary:#e8d5a3;
  --text-dim:    #8a7a5a;
  --danger:      #8b1a1a;
  --success:     #1a6b2a;
  --cell-size:   40px;
}

/* ─── Reset & Base ──────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background-color: var(--deep-water);
  color: var(--text-primary);
  font-family: 'Cinzel', 'Georgia', serif;
  overflow-x: hidden;
}

body {
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(18, 34, 68, 0.8) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(26, 58, 108, 0.4) 0%, transparent 50%),
    url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23122244' fill-opacity='0.3'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  min-height: 100vh;
}

/* ─── Screen Management ─────────────────────────────────────── */
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; flex-direction: column; padding-top: 48px; }
#auth-screen.active { padding-top: 0; }
.hidden { display: none !important; }

/* ─── Persistent Header ────────────────────────────────────── */
.persistent-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: rgba(10, 22, 40, 0.95);
  border-bottom: 1px solid var(--grid-line);
  backdrop-filter: blur(8px);
  padding: 10px 20px;
}
.header-content {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.header-title {
  font-family: 'Cinzel Decorative', 'Cinzel', serif;
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: color 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-icon {
  width: 28px;
  height: 28px;
}
.header-title:hover {
  color: var(--gold-light);
  text-shadow: 0 0 20px rgba(201, 168, 76, 0.4);
}
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.header-sound-btn {
  background: none;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  padding: 2px 4px;
  opacity: 0.7;
  transition: opacity 0.2s;
}
.header-sound-btn:hover { opacity: 1; }
.header-sound-btn.muted { opacity: 0.3; }
.header-username {
  color: var(--text-dim);
  font-size: 0.75rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  text-decoration: none;
  transition: color 0.2s;
}
.header-username:hover {
  color: var(--gold);
}
.header-tokens {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(201, 168, 76, 0.1);
  border: 1px solid var(--gold-dark);
  border-radius: 20px;
  padding: 4px 12px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.2s;
}
.header-tokens:hover {
  background: rgba(201, 168, 76, 0.2);
}
.token-icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: -0.1em;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='50' r='46' fill='%23c9a84c' stroke='%237a4218' stroke-width='4'/%3E%3Ccircle cx='50' cy='50' r='38' fill='none' stroke='%237a4218' stroke-width='2.5'/%3E%3Cline x1='30' y1='70' x2='55' y2='25' stroke='%235c3414' stroke-width='5' stroke-linecap='round'/%3E%3Cline x1='70' y1='70' x2='45' y2='25' stroke='%235c3414' stroke-width='5' stroke-linecap='round'/%3E%3Cpolygon points='50,22 44,34 56,34' fill='%235c3414'/%3E%3Cpolygon points='30,22 24,34 36,34' fill='%235c3414'/%3E%3Cpolygon points='70,22 64,34 76,34' fill='%235c3414'/%3E%3C/svg%3E") no-repeat center/contain;
  font-size: 0.85rem;
}
.token-count {
  color: var(--gold);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  font-family: 'Cinzel', serif;
}
.token-count.token-bump {
  animation: tokenBump 0.5s ease-out;
}
@keyframes tokenBump {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.4); color: var(--gold-light); }
  100% { transform: scale(1); }
}

/* ─── Persistent Footer ───────────────────────────────────── */
.persistent-footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1000;
  background: rgba(10, 22, 40, 0.95);
  border-top: 1px solid var(--grid-line);
  backdrop-filter: blur(8px);
  padding: 8px 20px;
}
.footer-content {
  max-width: 900px;
  margin: 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
}
.footer-content a {
  color: var(--text-dim);
  text-decoration: none;
  transition: color 0.2s;
}
.footer-content a:hover {
  color: var(--gold);
}
.footer-dot {
  color: var(--text-dim);
}

/* ─── Typography ────────────────────────────────────────────── */
h1, h2, h3, h4 { font-family: 'Cinzel', serif; letter-spacing: 0.05em; }

/* ─── Buttons ───────────────────────────────────────────────── */
.btn {
  font-family: 'Cinzel', serif;
  font-weight: 600;
  letter-spacing: 0.08em;
  border: none;
  cursor: pointer;
  padding: 12px 24px;
  border-radius: 4px;
  transition: all 0.2s ease;
  text-transform: uppercase;
  font-size: 0.85rem;
  position: relative;
  overflow: hidden;
}
.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.05);
  opacity: 0;
  transition: opacity 0.2s;
}
.btn:hover::after { opacity: 1; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.btn:disabled::after { display: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--gold-dark) 0%, var(--gold) 50%, var(--gold-dark) 100%);
  color: #1a0e00;
  border: 1px solid var(--gold-light);
  box-shadow: 0 0 20px rgba(201, 168, 76, 0.3), inset 0 1px 0 rgba(255,255,255,0.2);
}
.btn-primary:hover:not(:disabled) {
  box-shadow: 0 0 30px rgba(201, 168, 76, 0.5), inset 0 1px 0 rgba(255,255,255,0.3);
  transform: translateY(-1px);
}

.btn-secondary {
  background: linear-gradient(135deg, #1a2a4a 0%, #2a3a6a 100%);
  color: var(--gold);
  border: 1px solid var(--grid-line);
}
.btn-secondary:hover:not(:disabled) {
  border-color: var(--gold);
  box-shadow: 0 0 15px rgba(201, 168, 76, 0.2);
}

.btn-danger {
  background: linear-gradient(135deg, #4a1010 0%, #6b1e1e 100%);
  color: #ffaaaa;
  border: 1px solid #8b3030;
}
.btn-danger:hover:not(:disabled) {
  background: linear-gradient(135deg, #6b1e1e 0%, #8b2020 100%);
}

.btn-sm { padding: 8px 16px; font-size: 0.75rem; }

/* ─── Auth Screen ───────────────────────────────────────────── */
#auth-screen {
  justify-content: center;
  align-items: center;
  padding: 20px;
}

/* ─── Forgot Password Link ─────────────────────────────────── */
.forgot-link-wrapper {
  text-align: right;
  margin-top: -8px;
}
.forgot-link {
  color: var(--text-dim);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-decoration: none;
  transition: color 0.2s;
}
.forgot-link:hover {
  color: var(--gold);
}
.auth-provider-note {
  text-align: center;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  color: var(--text-dim);
  margin-top: 12px;
  text-transform: uppercase;
}
.username-prompt-intro {
  font-size: 0.85rem;
  color: var(--text-dim);
  text-align: center;
  margin-bottom: 16px;
  line-height: 1.5;
}

/* ─── Leaderboard ───────────────────────────────────────────── */
.leaderboard-card {
  width: 100%;
  max-width: 480px;
  background: rgba(10, 22, 40, 0.8);
  border: 1px solid var(--grid-line);
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 0 40px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.05);
}
.leaderboard-title {
  color: var(--gold);
  font-size: 0.9rem;
  letter-spacing: 0.15em;
  text-align: center;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--grid-line);
  padding-bottom: 10px;
}
.leaderboard-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
}
.leaderboard-table th {
  color: var(--gold-dark);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: left;
  padding: 6px 8px;
  border-bottom: 1px solid var(--grid-line);
}
.leaderboard-table td {
  padding: 8px;
  color: var(--text-primary);
  border-bottom: 1px solid rgba(26, 58, 92, 0.3);
}
.leaderboard-table tr:last-child td { border-bottom: none; }
.leaderboard-table tr:hover td { background: rgba(201, 168, 76, 0.05); }
.leaderboard-me td {
  color: var(--gold) !important;
  font-weight: 700;
}
.leaderboard-empty {
  text-align: center;
  color: var(--text-dim) !important;
  padding: 16px 8px !important;
}

/* ─── Profile Screen ────────────────────────────────────────── */
#profile-screen {
  justify-content: flex-start;
  align-items: center;
  padding: 68px 20px 44px 20px;
}
.profile-name {
  color: var(--gold);
  font-size: 1.8rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-shadow: 0 0 30px rgba(201, 168, 76, 0.5);
}
.profile-stats {
  gap: 20px;
}
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}
.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 12px 8px;
  background: rgba(18, 34, 68, 0.5);
  border-radius: 4px;
  border: 1px solid var(--grid-line);
}
.stat-value {
  font-size: 1.4rem;
  font-weight: 900;
  color: var(--text-primary);
}
.stat-label {
  font-size: 0.65rem;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.stat-wins .stat-value { color: var(--gold); }
.stat-losses .stat-value { color: var(--hit); }

/* ─── Game Breakdown (Profile) ────────────────────────────── */
.game-breakdown-section {
  padding: 12px 16px;
  background: rgba(201, 168, 76, 0.08);
  border: 1px solid var(--gold-dark);
  border-radius: 8px;
}
.game-breakdown {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}
.breakdown-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  border-bottom: 1px solid rgba(201, 168, 76, 0.1);
}
.breakdown-row:last-child { border-bottom: none; }
.breakdown-label {
  color: var(--text-secondary);
  font-size: 0.8rem;
}
.breakdown-value {
  color: var(--gold);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.05em;
}

/* ─── Token Treasury (Profile) ─────────────────────────────── */
.token-treasury {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 16px;
  background: rgba(201, 168, 76, 0.08);
  border: 1px solid var(--gold-dark);
  border-radius: 8px;
}
.treasury-icon {
  font-size: 1.5rem;
  color: var(--gold);
}
.treasury-value {
  font-size: 2rem;
  font-weight: 900;
  color: var(--gold);
  text-shadow: 0 0 20px rgba(201, 168, 76, 0.4);
}
.treasury-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.profile-skin-section {
  border-top: 1px solid var(--grid-line);
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.profile-section-title {
  color: var(--gold);
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-align: center;
}
.profile-skin-selector {
  display: flex;
  justify-content: center;
}
.profile-skin-selector select {
  background: rgba(18, 34, 68, 0.8);
  border: 1px solid var(--grid-line);
  border-radius: 4px;
  padding: 8px 14px;
  color: var(--text-primary);
  font-family: 'Cinzel', serif;
  font-size: 0.85rem;
  cursor: pointer;
  min-width: 180px;
  text-align: center;
}
.profile-skin-selector select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 15px rgba(201, 168, 76, 0.2);
}
.profile-skin-preview {
  display: flex;
  justify-content: center;
  padding: 12px;
  background: rgba(18, 34, 68, 0.4);
  border: 1px solid var(--grid-line);
  border-radius: 4px;
}
.profile-skin-preview svg {
  width: 280px;
  max-width: 100%;
  height: auto;
  display: block;
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ─── Page Title (lightweight replacement for logo-area) ──── */
.page-title {
  text-align: center;
  margin-bottom: 12px;
}

/* ─── Lobby Welcome Text ──────────────────────────────────── */
.lobby-welcome-text {
  color: var(--text-dim);
  font-size: 0.9rem;
  letter-spacing: 0.15em;
  text-align: center;
  text-transform: uppercase;
  margin-bottom: 16px;
}

/* ─── Lobby Screen ──────────────────────────────────────────── */
#lobby-screen {
  justify-content: flex-start;
  align-items: center;
  padding: 68px 20px 44px 20px;
}

.lobby-container {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 32px;
}

.logo-area {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.ship-illustration {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
  filter: drop-shadow(0 4px 16px rgba(201,168,76,0.3));
}

.game-title {
  font-family: 'Cinzel', serif;
  font-size: clamp(2.5rem, 8vw, 4rem);
  font-weight: 900;
  color: var(--gold);
  text-shadow:
    0 0 40px rgba(201, 168, 76, 0.6),
    0 0 80px rgba(201, 168, 76, 0.3),
    2px 2px 0 rgba(0,0,0,0.8);
  line-height: 1.1;
  letter-spacing: 0.1em;
}

.title-sub {
  font-size: 0.55em;
  color: var(--gold-light);
  letter-spacing: 0.3em;
}

.game-subtitle {
  color: var(--text-dim);
  font-size: 0.85rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.rune-border {
  width: 200px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
  position: relative;
}
.rune-border::before, .rune-border::after {
  content: '✦';
  position: absolute;
  color: var(--gold);
  top: -8px;
  font-size: 10px;
}
.rune-border::before { left: 30%; }
.rune-border::after { right: 30%; }

.lobby-card {
  width: 100%;
  background: rgba(10, 22, 40, 0.8);
  border: 1px solid var(--grid-line);
  border-radius: 8px;
  padding: 32px;
  box-shadow:
    0 0 40px rgba(0,0,0,0.6),
    inset 0 1px 0 rgba(255,255,255,0.05);
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.form-group label {
  font-size: 0.75rem;
  letter-spacing: 0.15em;
  color: var(--gold);
  text-transform: uppercase;
}
.form-group input {
  background: rgba(18, 34, 68, 0.8);
  border: 1px solid var(--grid-line);
  border-radius: 4px;
  padding: 10px 14px;
  color: var(--text-primary);
  font-family: 'Cinzel', serif;
  font-size: 0.9rem;
  width: 100%;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form-group input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 15px rgba(201, 168, 76, 0.2);
}
.form-group input::placeholder { color: var(--text-dim); }

#room-code-input {
  text-transform: uppercase;
  letter-spacing: 0.3em;
  font-size: 1.4rem;
  text-align: center;
}

.lobby-actions { display: flex; flex-direction: column; gap: 16px; }
.lobby-actions .btn { width: 100%; }

.divider {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.75rem;
  letter-spacing: 0.2em;
}

.join-section { display: flex; flex-direction: column; gap: 12px; }

.lobby-bottom-btns {
  display: flex;
  gap: 12px;
}
.lobby-bottom-btns .btn {
  flex: 1;
}

.bot-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.bot-select {
  background: rgba(18, 34, 68, 0.8);
  border: 1px solid var(--grid-line);
  border-radius: 4px;
  padding: 10px 14px;
  color: var(--text-primary);
  font-family: 'Cinzel', serif;
  font-size: 0.9rem;
  cursor: pointer;
  width: 100%;
}
.bot-select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 15px rgba(201, 168, 76, 0.2);
}
.bot-info {
  background: rgba(18, 34, 68, 0.5);
  border: 1px solid var(--grid-line);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--text-secondary);
}
.bot-info strong {
  color: var(--gold);
  font-family: 'Cinzel', serif;
}
.bot-bonus {
  color: var(--gold);
  font-weight: 600;
  font-size: 0.75rem;
}
.bot-bonus.none {
  color: var(--text-dim);
  font-weight: 400;
}
.bot-hint {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-align: center;
  margin: 0;
}

.lobby-message {
  padding: 12px 16px;
  border-radius: 4px;
  font-size: 0.85rem;
  text-align: center;
}
.lobby-message.error {
  background: rgba(139, 26, 26, 0.3);
  border: 1px solid var(--danger);
  color: #ffaaaa;
}
.lobby-message.info {
  background: rgba(26, 107, 42, 0.3);
  border: 1px solid var(--success);
  color: #aaffcc;
}

.waiting-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px;
  border: 1px dashed var(--gold-dark);
  border-radius: 4px;
  background: rgba(201, 168, 76, 0.05);
}
.waiting-panel p { color: var(--text-dim); font-size: 0.85rem; }
.btn-copy-link { margin: 8px 0; font-size: 0.75rem; padding: 6px 16px; }
.waiting-text { color: var(--gold) !important; animation: pulse 2s ease-in-out infinite; }

.room-code-display {
  font-size: 1.8rem;
  color: var(--gold);
  letter-spacing: 0.3em;
  font-weight: 900;
  text-shadow: 0 0 20px rgba(201, 168, 76, 0.5);
}

.waiting-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--grid-line);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* ─── Store Screen ──────────────────────────────────────────── */
#store-screen {
  justify-content: flex-start;
  align-items: center;
  padding: 68px 20px 44px 20px;
}
.store-container {
  width: 100%;
  max-width: 700px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}
.store-title {
  color: var(--gold);
  font-size: 1.8rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-shadow: 0 0 30px rgba(201, 168, 76, 0.5);
}
.store-balance {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(201, 168, 76, 0.08);
  border: 1px solid var(--gold-dark);
  border-radius: 20px;
  padding: 8px 20px;
}
.store-balance .token-icon { font-size: 1.1rem; }
.store-balance-count {
  color: var(--gold);
  font-weight: 900;
  font-size: 1.2rem;
  font-family: 'Cinzel', serif;
}
.store-balance-label {
  color: var(--text-dim);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.store-categories {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.store-category-title {
  color: var(--gold);
  font-size: 0.9rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--grid-line);
  padding-bottom: 8px;
  margin-bottom: 12px;
}
.store-category-icon {
  margin-right: 4px;
}
.store-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  width: 100%;
}
.store-item {
  background: rgba(10, 22, 40, 0.8);
  border: 1px solid var(--grid-line);
  border-radius: 8px;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.store-item:hover {
  border-color: var(--gold-dark);
  box-shadow: 0 0 20px rgba(201, 168, 76, 0.15);
}
.store-item-preview {
  width: 100%;
  height: 60px;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(18, 34, 68, 0.4);
  border-radius: 4px;
  overflow: hidden;
}
.store-item-preview svg {
  max-width: 100%;
  max-height: 100%;
}
.store-item-name {
  color: var(--gold);
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-align: center;
}
.store-item-tag {
  font-size: 0.6rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 700;
}
.permanent-tag {
  background: rgba(100, 200, 150, 0.15);
  color: #8fd8b0;
  border: 1px solid rgba(100, 200, 150, 0.3);
}
.consumable-tag {
  background: rgba(200, 160, 80, 0.15);
  color: var(--gold);
  border: 1px solid rgba(200, 160, 80, 0.3);
}
.store-item-desc {
  color: var(--text-dim);
  font-size: 0.7rem;
  text-align: center;
  letter-spacing: 0.05em;
}
.store-item-price {
  display: flex;
  align-items: center;
  gap: 4px;
  color: var(--gold);
  font-weight: 700;
  font-size: 0.9rem;
}
.store-item .btn {
  width: 100%;
  font-size: 0.75rem;
  padding: 8px 12px;
}
.store-item .btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.store-item.owned {
  border-color: var(--success);
}
.store-item.coming-soon {
  opacity: 0.5;
  pointer-events: none;
}
.coming-soon-badge {
  color: var(--text-dim);
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-style: italic;
}
.store-item.owned .store-item-badge {
  color: #aaffcc;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.store-item-qty {
  color: var(--gold);
  font-size: 0.8em;
  margin-bottom: 6px;
  letter-spacing: 0.05em;
}

/* ─── Placement Screen ──────────────────────────────────────── */
#placement-screen {
  padding: 64px 16px 44px 16px;
  align-items: stretch;
  gap: 16px;
}

.placement-header {
  text-align: center;
  padding: 16px;
  border-bottom: 1px solid var(--grid-line);
}
.placement-header h2 {
  color: var(--gold);
  font-size: 1.5rem;
}
.placement-status {
  color: var(--text-dim);
  font-size: 0.8rem;
  margin-top: 6px;
  letter-spacing: 0.1em;
}
.opponent-label {
  color: var(--miss);
  font-size: 0.8rem;
  margin-top: 4px;
}

.placement-layout {
  display: flex;
  flex: 1;
  gap: 24px;
  padding: 16px;
  align-items: flex-start;
  justify-content: center;
  flex-wrap: wrap;
}

/* Ship Tray */
.ship-tray {
  background: rgba(10, 22, 40, 0.6);
  border: 1px solid var(--grid-line);
  border-radius: 8px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 200px;
  max-width: 240px;
}
.ship-tray h3 {
  color: var(--gold);
  font-size: 0.9rem;
  letter-spacing: 0.15em;
  border-bottom: 1px solid var(--grid-line);
  padding-bottom: 10px;
}

.ship-list { display: flex; flex-direction: column; gap: 10px; }

.ship-item {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s;
  background: rgba(18, 34, 68, 0.5);
}
.ship-item:hover:not(.placed) {
  border-color: var(--gold-dark);
  background: rgba(201, 168, 76, 0.08);
}
.ship-item.selected {
  border-color: var(--gold);
  background: rgba(201, 168, 76, 0.15);
  box-shadow: 0 0 15px rgba(201, 168, 76, 0.2);
}
.ship-item.placed {
  opacity: 0.4;
  cursor: not-allowed;
}
.ship-item.consumable {
  border-left: 3px solid #4caf50;
}
.ship-item-name {
  font-size: 0.75rem;
  color: var(--gold);
  letter-spacing: 0.1em;
}
.ship-item-size {
  font-size: 0.65rem;
  color: var(--text-dim);
}
.ship-visual {
  display: flex;
  gap: 2px;
}
.ship-cell-preview {
  width: 18px;
  height: 18px;
  background: var(--ship-color);
  border-radius: 2px;
  border: 1px solid var(--ship-light);
}
.ship-item.selected .ship-cell-preview {
  background: var(--gold-dark);
  border-color: var(--gold);
}
.ship-item.placed .ship-cell-preview {
  background: #2a2a2a;
  border-color: #444;
}

.skin-selector {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.skin-selector label {
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--gold);
  text-transform: uppercase;
}
.skin-selector select {
  background: rgba(18, 34, 68, 0.8);
  border: 1px solid var(--grid-line);
  border-radius: 4px;
  padding: 6px 10px;
  color: var(--text-primary);
  font-family: 'Cinzel', serif;
  font-size: 0.8rem;
  cursor: pointer;
}
.skin-selector select:focus {
  outline: none;
  border-color: var(--gold);
}

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

.btn-ready {
  margin-top: 8px;
  font-size: 0.85rem !important;
  padding: 14px 20px !important;
}

.placement-waiting {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-dim);
  font-size: 0.8rem;
  padding: 10px;
  border: 1px dashed var(--grid-line);
  border-radius: 4px;
}
.placement-waiting .waiting-spinner {
  width: 20px;
  height: 20px;
  border-width: 2px;
  flex-shrink: 0;
}

.placement-board-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}
.board-label {
  font-size: 0.8rem;
  letter-spacing: 0.15em;
  color: var(--gold);
  text-transform: uppercase;
}
.placement-hint {
  font-size: 0.72rem;
  color: var(--text-dim);
  text-align: center;
  max-width: 420px;
  line-height: 1.5;
}

/* ─── Boards (shared) ───────────────────────────────────────── */
.board {
  display: grid;
  grid-template-columns: repeat(10, var(--cell-size));
  grid-template-rows: repeat(10, var(--cell-size));
  gap: 1px;
  background: var(--grid-line);
  border: 2px solid var(--grid-line);
  border-radius: 2px;
  box-shadow:
    0 0 30px rgba(0, 0, 0, 0.5),
    inset 0 0 20px rgba(10, 22, 40, 0.5);
  user-select: none;
  position: relative;
  overflow: hidden;
}

.cell {
  width: var(--cell-size);
  height: var(--cell-size);
  background: var(--mid-water);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: background 0.15s;
  font-size: 14px;
}

/* ── Ship overlay illustrations ── */
.ship-overlay {
  position: absolute;
  pointer-events: none;
  z-index: 2;
  line-height: 0;
}
.sunk-overlay {
  opacity: 0.45;
  filter: grayscale(0.5);
}

/* ── Impact effects (hit explosion / miss splash) ── */
.impact-fx {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}
.impact-fx.explosion::before {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 100%; height: 100%;
  transform: translate(-50%, -50%) scale(0);
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, var(--hit-light) 40%, transparent 70%);
  animation: impactFlash 0.4s ease-out forwards;
}
.impact-fx.splash::before {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  width: 80%; height: 80%;
  transform: translate(-50%, -50%) scale(0);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.8) 0%, var(--miss-light) 50%, transparent 70%);
  animation: impactFlash 0.35s ease-out forwards;
}
.particle {
  position: absolute;
  top: 50%; left: 50%;
  width: 4px; height: 4px;
  border-radius: 50%;
  transform: translate(-50%, -50%);
  animation: particleBurst 0.4s ease-out forwards;
}
.explosion .particle {
  background: var(--hit-light);
  box-shadow: 0 0 4px var(--hit);
}
.splash .particle {
  background: var(--miss-light);
  box-shadow: 0 0 3px var(--miss);
  width: 3px; height: 3px;
}

@keyframes impactFlash {
  0%   { transform: translate(-50%, -50%) scale(0); opacity: 1; }
  50%  { transform: translate(-50%, -50%) scale(1.2); opacity: 0.8; }
  100% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
}
@keyframes particleBurst {
  0%   { transform: translate(-50%, -50%) translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) translate(var(--tx), var(--ty)) scale(0); opacity: 0; }
}
.ship-overlay svg {
  width: 100%;
  height: 100%;
  display: block;
}

/* ── Placement board cells ── */
.placement-board .cell { cursor: crosshair; }
.placement-board .cell:hover { background: rgba(201, 168, 76, 0.15); }
.placement-board .cell.ship {
  background: transparent;
  border: none;
}
.placement-board .cell.preview-valid {
  background: rgba(92, 61, 30, 0.5);
  border: 1px dashed var(--gold);
}
.placement-board .cell.preview-invalid {
  background: rgba(232, 75, 26, 0.25);
  border: 1px dashed var(--hit);
}

/* ── Home board cells (battle) ── */
#home-board .cell {
  cursor: default;
}
#home-board .cell.ship {
  background: transparent;
  border: none;
}
#home-board .cell.ship.hit {
  background: var(--hit);
  position: relative;
  z-index: 3;
}
#home-board .cell.ship.sunk {
  background: rgba(60,60,60,0.85);
  position: relative;
  z-index: 3;
}
#home-board .cell.miss {
  background: var(--miss);
  position: relative;
  z-index: 3;
}

/* ── Enemy board cells (battle) ── */
#enemy-board .cell {
  cursor: crosshair;
}
#enemy-board .cell.my-turn:hover {
  background: rgba(201, 168, 76, 0.25);
  box-shadow: inset 0 0 8px rgba(201, 168, 76, 0.3);
}
#enemy-board .cell.hit {
  background: var(--hit);
}
#enemy-board .cell.miss {
  background: var(--miss);
}
#enemy-board .cell.sunk {
  background: #555;
}
#enemy-board .cell.hit::after,
#enemy-board .cell.sunk::after {
  content: '✕';
  font-size: 18px;
  color: rgba(255,255,255,0.9);
  font-weight: bold;
}
#enemy-board .cell.miss::after {
  content: '·';
  font-size: 24px;
  color: rgba(255,255,255,0.6);
}
#home-board .cell.ship.hit::after {
  content: '✕';
  font-size: 18px;
  color: rgba(255,255,255,0.9);
  font-weight: bold;
}
#home-board .cell.miss::after {
  content: '·';
  font-size: 24px;
  color: rgba(255,255,255,0.6);
}

/* ─── Game Screen ───────────────────────────────────────────── */
#game-screen {
  padding: 48px 0 0 0;
  gap: 0;
}

.turn-banner {
  padding: 14px 24px;
  text-align: center;
  background: rgba(10, 22, 40, 0.9);
  border-bottom: 2px solid var(--grid-line);
  font-size: 1rem;
  letter-spacing: 0.15em;
  font-weight: 600;
  position: sticky;
  top: 44px;
  z-index: 100;
  transition: all 0.3s;
}
.turn-banner.my-turn {
  background: rgba(201, 168, 76, 0.12);
  border-bottom-color: var(--gold);
  color: var(--gold);
  animation: turnPulse 2s ease-in-out infinite;
}
.turn-banner.enemy-turn {
  background: rgba(74, 111, 165, 0.12);
  border-bottom-color: var(--miss);
  color: var(--miss-light);
}

.boards-container {
  display: flex;
  gap: 32px;
  padding: 20px;
  justify-content: center;
  align-items: flex-start;
  flex-wrap: wrap;
  flex: 1;
}

.board-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.board-header {
  text-align: center;
}
.board-header h2 {
  color: var(--gold);
  font-size: 1rem;
  letter-spacing: 0.15em;
}
.board-desc {
  color: var(--text-dim);
  font-size: 0.75rem;
  margin-top: 2px;
}

/* ── Raven's Eye ── */
.btn-ravens-eye {
  background: rgba(138, 100, 200, 0.2);
  border: 1px solid rgba(138, 100, 200, 0.5);
  color: #c9a0ff;
  font-size: 0.75rem;
  margin-top: 6px;
  transition: all 0.2s;
}
.btn-ravens-eye:hover:not(:disabled) {
  background: rgba(138, 100, 200, 0.35);
  border-color: #c9a0ff;
  box-shadow: 0 0 12px rgba(138, 100, 200, 0.3);
}
.btn-ravens-eye:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
/* ── Surtr's Flame (Fire Arrows) ── */
.btn-fire-arrows {
  background: rgba(232, 100, 26, 0.2);
  border: 1px solid rgba(232, 100, 26, 0.5);
  color: #ff8844;
  font-size: 0.75rem;
  margin-top: 6px;
  transition: all 0.2s;
}
.btn-fire-arrows:hover:not(:disabled) {
  background: rgba(232, 100, 26, 0.35);
  border-color: #ff8844;
  box-shadow: 0 0 12px rgba(232, 100, 26, 0.3);
}
.btn-fire-arrows:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-fire-arrows.active-item {
  background: rgba(232, 100, 26, 0.3);
  border-color: #ff8844;
  box-shadow: 0 0 8px rgba(232, 100, 26, 0.4);
}

/* ── Aegir's Tide ── */
.btn-aegirs-tide {
  background: rgba(58, 140, 200, 0.2);
  border: 1px solid rgba(58, 140, 200, 0.5);
  color: #66bbee;
  font-size: 0.75rem;
  margin-top: 6px;
  transition: all 0.2s;
}
.btn-aegirs-tide:hover:not(:disabled) {
  background: rgba(58, 140, 200, 0.35);
  border-color: #66bbee;
  box-shadow: 0 0 12px rgba(58, 140, 200, 0.3);
}
.btn-aegirs-tide:disabled { opacity: 0.4; cursor: not-allowed; }
.btn-aegirs-tide.active-item {
  background: rgba(58, 140, 200, 0.3);
  border-color: #66bbee;
  box-shadow: 0 0 8px rgba(58, 140, 200, 0.4);
}

/* ── Thor's Hammer ── */
.btn-thors-hammer {
  background: rgba(180, 160, 60, 0.2);
  border: 1px solid rgba(180, 160, 60, 0.5);
  color: #e8d060;
  font-size: 0.75rem;
  margin-top: 6px;
  transition: all 0.2s;
}
.btn-thors-hammer:hover:not(:disabled) {
  background: rgba(180, 160, 60, 0.35);
  border-color: #e8d060;
  box-shadow: 0 0 12px rgba(180, 160, 60, 0.3);
}
.btn-thors-hammer:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.turn-banner.thors-hammer-mode {
  background: linear-gradient(90deg, rgba(180, 160, 60, 0.3), rgba(160, 140, 40, 0.3));
  border-color: rgba(180, 160, 60, 0.5);
}
.cell.thors-hammer-target {
  box-shadow: inset 0 0 8px rgba(232, 208, 96, 0.6), 0 0 6px rgba(232, 208, 96, 0.3);
  background: rgba(232, 208, 96, 0.2) !important;
}

/* ── Loki Hunter ── */
.btn-loki-hunter {
  background: rgba(200, 80, 60, 0.2);
  border: 1px solid rgba(200, 80, 60, 0.5);
  color: #e8a070;
  font-size: 0.75rem;
  margin-top: 6px;
  transition: all 0.2s;
}
.btn-loki-hunter:hover:not(:disabled) {
  background: rgba(200, 80, 60, 0.35);
  border-color: #e8a070;
  box-shadow: 0 0 12px rgba(200, 80, 60, 0.3);
}
.btn-loki-hunter:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-odins-rage {
  background: rgba(100, 80, 200, 0.2);
  border: 1px solid rgba(100, 80, 200, 0.5);
  color: #b8a0e8;
}
.btn-odins-rage:hover:not(:disabled) {
  background: rgba(100, 80, 200, 0.35);
  border-color: #b8a0e8;
  box-shadow: 0 0 12px rgba(100, 80, 200, 0.3);
}
.btn-odins-rage:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.turn-banner.ravens-eye-mode {
  background: linear-gradient(90deg, rgba(138, 100, 200, 0.3), rgba(100, 80, 180, 0.3));
  border-color: rgba(138, 100, 200, 0.5);
}
.cell.ravens-eye-reveal {
  position: relative;
  z-index: 1;
}
.cell.ravens-eye-ship {
  background: rgba(232, 75, 26, 0.35) !important;
  box-shadow: inset 0 0 8px rgba(232, 75, 26, 0.6), 0 0 6px rgba(232, 75, 26, 0.3);
  animation: ravensGlow 1.2s ease-in-out infinite alternate;
}
.cell.ravens-eye-water {
  background: rgba(58, 111, 160, 0.2) !important;
  box-shadow: inset 0 0 6px rgba(58, 111, 160, 0.4);
}
@keyframes ravensGlow {
  from { box-shadow: inset 0 0 8px rgba(232, 75, 26, 0.6), 0 0 6px rgba(232, 75, 26, 0.3); }
  to   { box-shadow: inset 0 0 12px rgba(232, 75, 26, 0.8), 0 0 10px rgba(232, 75, 26, 0.5); }
}

.ship-legend {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 100%;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.7rem;
  color: var(--text-dim);
}
.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  background: var(--ship-color);
  border: 1px solid var(--ship-light);
  flex-shrink: 0;
}
.legend-dot.sunk { background: #444; border-color: #666; }

.sunk-ships-log {
  background: rgba(10, 22, 40, 0.5);
  border: 1px solid var(--grid-line);
  border-radius: 4px;
  padding: 12px;
  width: 100%;
}
.sunk-ships-log h4 {
  color: var(--gold);
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--grid-line);
  padding-bottom: 6px;
}
.sunk-list { display: flex; flex-direction: column; gap: 4px; }
.no-sunk {
  color: var(--text-dim);
  font-size: 0.75rem;
}
.sunk-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: #aaa;
  animation: fadeIn 0.4s ease-out;
}
.sunk-item::before { content: '⚓'; }

/* ─── Message Log ───────────────────────────────────────────── */
.message-log {
  background: rgba(10, 22, 40, 0.8);
  border-top: 1px solid var(--grid-line);
  padding: 12px 20px 44px 20px;
  max-height: 170px;
  overflow-y: auto;
}
.messages { display: flex; flex-direction: column; gap: 4px; }
.msg {
  font-size: 0.8rem;
  padding: 4px 8px;
  border-left: 3px solid transparent;
  animation: fadeIn 0.3s ease-out;
  line-height: 1.4;
}
.msg.hit-msg   { border-color: var(--hit); color: #ff9977; }
.msg.miss-msg  { border-color: var(--miss); color: var(--miss-light); }
.msg.sunk-msg  { border-color: var(--gold); color: var(--gold); }
.msg.info-msg  { border-color: var(--grid-line); color: var(--text-dim); }
.msg.turn-msg  { border-color: var(--gold-dark); color: var(--gold-light); }

/* ─── Victory Screen ────────────────────────────────────────── */
#victory-screen {
  justify-content: flex-start;
  align-items: center;
  background: radial-gradient(ellipse at center, rgba(201, 168, 76, 0.15) 0%, transparent 70%);
  overflow-y: auto;
  padding-top: 80px;
}

.victory-container {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 40px;
  max-width: 500px;
}

.victory-runes {
  font-size: 3rem;
  animation: float 3s ease-in-out infinite;
}
.victory-runes::before { content: '⚔'; }

.victory-title {
  font-size: clamp(2.5rem, 10vw, 5rem);
  font-weight: 900;
  color: var(--gold);
  text-shadow:
    0 0 40px rgba(201, 168, 76, 0.8),
    0 0 80px rgba(201, 168, 76, 0.4);
  animation: victoryGlow 2s ease-in-out infinite alternate;
}

.victory-subtitle {
  font-size: 1.1rem;
  color: var(--text-primary);
  letter-spacing: 0.1em;
}

.victory-divider {
  color: var(--gold-dark);
  letter-spacing: 0.5em;
}

.victory-container .btn { width: 200px; max-width: 90%; }

/* ─── Battle Reveal ────────────────────────────────────────── */
.battle-reveal {
  width: 100%;
  max-width: 900px;
  margin: 24px auto 0;
  padding: 0 16px 40px;
}
.reveal-title {
  text-align: center;
  color: var(--gold);
  font-family: 'Cinzel', serif;
  font-size: 1.4rem;
  margin-bottom: 16px;
  letter-spacing: 0.1em;
}
.reveal-stats-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.reveal-vs {
  color: var(--gold-dark);
  font-family: 'Cinzel', serif;
  font-size: 1.2rem;
  font-weight: 700;
}
.reveal-player-stats {
  background: var(--dark-sea);
  border: 1px solid var(--gold-dark);
  border-radius: 10px;
  padding: 12px 18px;
  min-width: 200px;
  text-align: center;
}
.reveal-player-stats .rps-name {
  font-family: 'Cinzel', serif;
  color: var(--gold);
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 8px;
}
.reveal-player-stats .rps-name.winner { color: #ffd700; text-shadow: 0 0 10px rgba(255, 215, 0, 0.5); }
.reveal-player-stats .rps-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px 12px;
  font-size: 0.82rem;
}
.reveal-player-stats .rps-label { color: var(--text-secondary); text-align: right; }
.reveal-player-stats .rps-val { color: var(--text-primary); font-weight: 600; text-align: left; }
.reveal-player-stats .rps-val.hit-color { color: var(--hit-color); }
.reveal-player-stats .rps-val.miss-color { color: var(--miss-color); }
.reveal-player-stats .rps-val.gold-color { color: var(--gold); }

.reveal-boards-row {
  display: flex;
  justify-content: center;
  gap: 24px;
  flex-wrap: wrap;
}
.reveal-board-panel {
  text-align: center;
}
.reveal-board-label {
  font-family: 'Cinzel', serif;
  color: var(--text-primary);
  font-size: 0.95rem;
  margin-bottom: 8px;
}
.reveal-board-wrapper {
  --cell-size: 28px;
}
.reveal-board {
  position: relative;
}
.reveal-board .cell.hit {
  background: var(--hit);
  position: relative;
  z-index: 3;
}
.reveal-board .cell.hit::after {
  content: '✕';
  font-size: 16px;
  color: rgba(255,255,255,0.9);
  font-weight: bold;
}
.reveal-board .cell.miss {
  background: var(--miss);
  position: relative;
  z-index: 3;
}
.reveal-board .cell.miss::after {
  content: '·';
  font-size: 22px;
  color: rgba(255,255,255,0.6);
}
@media (max-width: 640px) {
  .reveal-boards-row { flex-direction: column; align-items: center; gap: 16px; }
  .reveal-player-stats { min-width: 140px; padding: 10px 12px; }
  .reveal-stats-row { gap: 10px; }
  .reveal-vs { font-size: 1rem; }
  .reveal-title { font-size: 1.1rem; }
  .battle-reveal { padding: 0 10px 30px; }
}
@media (max-width: 480px) {
  #victory-screen { padding-top: 56px; }
  .reveal-board-wrapper { --cell-size: calc((100vw - 40px) / 10.9); }
  .reveal-player-stats { min-width: 120px; padding: 8px 10px; }
  .reveal-player-stats .rps-name { font-size: 0.85rem; }
  .reveal-player-stats .rps-grid { font-size: 0.75rem; gap: 3px 8px; }
  .reveal-board-label { font-size: 0.82rem; }
  .reveal-title { font-size: 1rem; margin-bottom: 10px; }
}
@media (max-width: 360px) {
  #victory-screen { padding-top: 50px; }
  .reveal-board-wrapper { --cell-size: calc((100vw - 32px) / 10.9); }
  .reveal-player-stats { min-width: 100px; }
  .reveal-player-stats .rps-grid { font-size: 0.7rem; gap: 2px 6px; }
}

/* ─── Animations ────────────────────────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

@keyframes turnPulse {
  0%, 100% { box-shadow: 0 2px 20px rgba(201, 168, 76, 0.2); }
  50% { box-shadow: 0 2px 40px rgba(201, 168, 76, 0.5); }
}

@keyframes hitFlare {
  0%   { background: #fff; transform: scale(1.1); }
  30%  { background: var(--hit-light); transform: scale(1.05); }
  100% { background: var(--hit); transform: scale(1); }
}

@keyframes ripple {
  0%   { box-shadow: 0 0 0 0 rgba(74, 111, 165, 0.8); }
  100% { box-shadow: 0 0 0 10px rgba(74, 111, 165, 0); }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

@keyframes victoryGlow {
  from { text-shadow: 0 0 40px rgba(201, 168, 76, 0.6), 0 0 80px rgba(201, 168, 76, 0.3); }
  to   { text-shadow: 0 0 60px rgba(201, 168, 76, 1.0), 0 0 120px rgba(201, 168, 76, 0.6); }
}

@keyframes sunkShake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-3px); }
  40% { transform: translateX(3px); }
  60% { transform: translateX(-2px); }
  80% { transform: translateX(2px); }
}

.cell.sunk-anim { animation: sunkShake 0.5s ease-in-out; }

/* ─── Scrollbar ─────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--deep-water); }
::-webkit-scrollbar-thumb {
  background: var(--grid-line);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: var(--gold-dark); }

/* ─── Responsive ────────────────────────────────────────────── */

/* Tablet / small laptop */
@media (max-width: 900px) {
  :root { --cell-size: 34px; }

  .boards-container {
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 10px;
  }

  .placement-layout {
    flex-direction: column;
    align-items: center;
    gap: 16px;
  }
  .ship-tray {
    width: 100%;
    max-width: 100%;
  }
  .ship-list {
    flex-direction: row;
    flex-wrap: wrap;
  }
  .ship-item {
    flex: 1;
    min-width: 120px;
  }
  .placement-controls {
    flex-direction: row;
    flex-wrap: wrap;
  }
}

/* Large phone / small tablet */
@media (max-width: 768px) {
  :root { --cell-size: 32px; }

  .persistent-header { padding: 8px 12px; }
  .persistent-footer { padding: 6px 12px; }
  .header-icon { width: 24px; height: 24px; }

  .boards-container { gap: 12px; padding: 8px; }
  .board-header h2 { font-size: 0.85rem; }

  .placement-layout { gap: 12px; padding: 8px; }
  .ship-tray { padding: 14px; }

  .message-log { padding: 10px 12px 44px 12px; max-height: 140px; }

  .victory-subtitle { font-size: 0.95rem; }
}

/* Phone */
@media (max-width: 480px) {
  :root { --cell-size: 28px; }

  .persistent-header { padding: 6px 10px; }
  .header-title { font-size: 0.65rem; letter-spacing: 0.04em; }
  .header-icon { width: 20px; height: 20px; }
  .header-right { gap: 6px; }
  .header-tokens { padding: 3px 8px; font-size: 0.65rem; }
  .header-username { font-size: 0.65rem; }
  .header-sound-btn { font-size: 0.85rem; padding: 4px 6px; }

  .lobby-card { padding: 16px; }
  .game-title { font-size: 1.8rem; }
  #room-code-input { font-size: 1.1rem; }
  .btn-copy-link { font-size: 0.7rem; padding: 8px 14px; }

  .leaderboard-table { font-size: 0.7rem; }
  .leaderboard-table th { font-size: 0.65rem; padding: 6px; }
  .leaderboard-table td { padding: 6px; }

  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 8px; }

  .turn-banner { font-size: 0.8rem; padding: 8px; }

  .boards-container { gap: 10px; padding: 4px; }
  .board-section { gap: 6px; }
  .board-header h2 { font-size: 0.75rem; }
  .board-desc { font-size: 0.65rem; }

  .ship-legend { gap: 2px; }
  .legend-item { font-size: 0.6rem; gap: 4px; }
  .legend-dot { width: 10px; height: 10px; }

  .sunk-ships-log { padding: 8px; }
  .sunk-ships-log h4 { font-size: 0.65rem; }
  .sunk-item { font-size: 0.65rem; }

  .message-log { padding: 8px 10px 44px 10px; max-height: 120px; }
  .msg { font-size: 0.7rem; padding: 3px 6px; }

  .placement-layout { gap: 8px; padding: 4px; }
  .ship-tray { padding: 10px; gap: 10px; }
  .ship-tray h3 { font-size: 0.8rem; }
  .ship-item { padding: 8px; gap: 4px; min-width: 100px; }
  .placement-hint { max-width: 90vw; font-size: 0.65rem; }

  .store-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
  .store-item { padding: 14px; }

  .victory-container { padding: 20px 16px; gap: 14px; }
  .victory-subtitle { font-size: 0.85rem; }
  .victory-divider { letter-spacing: 0.3em; }

  #placement-screen { padding: 50px 4px 44px 4px; }
  #game-screen { padding: 42px 0 0 0; }
}

/* Small phone */
@media (max-width: 360px) {
  :root { --cell-size: 25px; }

  .header-title { font-size: 0.6rem; gap: 4px; }
  .header-icon { width: 18px; height: 18px; }

  .lobby-card { padding: 12px; }
  .ship-item { min-width: 80px; padding: 6px; }
  .stats-grid { gap: 6px; }
  .store-grid { grid-template-columns: 1fr; }
  .btn-sm { padding: 8px 12px; font-size: 0.7rem; }
}

/* ─── Legal Pages (Privacy, Terms) ─────────────────────────── */
.legal-page {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 40px 20px;
}
.legal-container {
  max-width: 640px;
  width: 100%;
}
.legal-back {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  transition: color 0.2s;
}
.legal-back:hover {
  color: var(--gold);
}
.legal-title {
  color: var(--gold);
  font-size: 2rem;
  margin-top: 20px;
  margin-bottom: 4px;
}
.legal-updated {
  color: var(--text-dim);
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  margin-bottom: 32px;
}
.legal-content {
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.legal-content h2 {
  color: var(--gold-light);
  font-size: 1rem;
  letter-spacing: 0.1em;
  margin-bottom: 8px;
}
.legal-content p {
  color: var(--text-dim);
  font-size: 0.85rem;
  line-height: 1.7;
  font-family: 'Cinzel', serif;
}
.legal-content a {
  color: var(--text-primary);
  text-decoration: none;
  transition: color 0.2s;
}
.legal-content a:hover {
  color: var(--gold);
  text-decoration: underline;
}
