/* style.css — Caribbean Blade */
:root {
  --gold: #d4a843;
  --gold-bright: #f0c860;
  --parchment: #e8d5a8;
  --ocean: #0a1929;
  --ocean-mid: #16456e;
  --crimson: #c0392b;
  --crimson-bright: #e74c3c;
  --wood: #6b4a2a;
  --wood-dark: #3a2a1a;
  --bg: #0a1929;
  --text: #e8d5a8;
  --text-dim: #a89878;
  --panel: rgba(20, 35, 55, 0.92);
  --border: rgba(212, 168, 67, 0.3);
  --font-display: Georgia, 'Times New Roman', serif;
  --font-body: Georgia, 'Times New Roman', serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #1a3050;
    --text: #f0e8d0;
    --text-dim: #c8b898;
    --panel: rgba(30, 50, 75, 0.92);
  }
}

html[data-theme="dark"] {
  --bg: #0a1929;
  --text: #e8d5a8;
  --text-dim: #a89878;
  --panel: rgba(20, 35, 55, 0.92);
}

html[data-theme="light"] {
  --bg: #1a3050;
  --text: #f0e8d0;
  --text-dim: #c8b898;
  --panel: rgba(30, 50, 75, 0.92);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}

canvas {
  position: fixed;
  top: 0; left: 0;
  display: block;
  touch-action: none;
}

.hidden { display: none !important; }

/* ============ SCREENS ============ */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  background: radial-gradient(ellipse at center, rgba(10, 25, 41, 0.85) 0%, rgba(5, 12, 20, 0.97) 100%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.screen-active {
  opacity: 1;
  pointer-events: auto;
}

.title-content {
  text-align: center;
  max-width: 560px;
  padding: 32px 24px;
  position: relative;
}

.eyebrow {
  font-size: 13px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 8px;
  opacity: 0.8;
}

.game-title {
  font-family: var(--font-display);
  font-size: clamp(48px, 10vw, 84px);
  line-height: 1;
  color: var(--gold-bright);
  text-shadow: 0 0 30px rgba(212, 168, 67, 0.4), 3px 3px 0 rgba(0,0,0,0.5);
  letter-spacing: 0.02em;
  margin-bottom: 4px;
  font-weight: 700;
  font-style: italic;
}

.subtitle {
  font-family: var(--font-body);
  font-size: clamp(14px, 3vw, 20px);
  color: var(--parchment);
  letter-spacing: 0.15em;
  text-transform: uppercase;
  margin-bottom: 24px;
  opacity: 0.85;
  font-weight: 600;
}

.story {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 22px;
  margin-bottom: 28px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  text-align: left;
}

.story em {
  color: var(--gold);
  font-style: italic;
}

.btn-primary {
  font-family: var(--font-display);
  font-size: 24px;
  letter-spacing: 0.08em;
  color: #1a0a00;
  background: linear-gradient(135deg, var(--gold-bright), var(--gold));
  border: none;
  padding: 14px 48px;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(212, 168, 67, 0.4), inset 0 1px 0 rgba(255,255,255,0.3);
  transition: transform 0.15s, box-shadow 0.15s;
  text-transform: uppercase;
  font-weight: 700;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 28px rgba(212, 168, 67, 0.5), inset 0 1px 0 rgba(255,255,255,0.4);
}

.btn-primary:active {
  transform: translateY(0);
}

.controls-hint {
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--text-dim);
}

.ctrl-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.ctrl-key {
  display: inline-block;
  background: rgba(212, 168, 67, 0.15);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  font-family: ui-monospace, 'SF Mono', Consolas, monospace;
  font-size: 12px;
  color: var(--gold);
  min-width: 28px;
  text-align: center;
}

/* ============ HUD ============ */
.hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 50;
  pointer-events: none;
}

.hud-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  gap: 12px;
  background: linear-gradient(180deg, rgba(10, 20, 35, 0.8) 0%, transparent 100%);
}

.hud-stat {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 100px;
}

.hud-stat.hud-center {
  align-items: center;
}

.hud-stat:last-child {
  align-items: flex-end;
}

.hud-label {
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.hud-gold {
  font-family: var(--font-display);
  font-size: 28px;
  color: var(--gold-bright);
  line-height: 1;
  text-shadow: 0 2px 8px rgba(0,0,0,0.5);
  font-weight: 700;
}

.hud-count {
  font-family: var(--font-display);
  font-size: 20px;
  color: var(--parchment);
  font-weight: 700;
}

.bar-wrap {
  width: 140px;
  height: 10px;
  background: rgba(0,0,0,0.5);
  border: 1px solid var(--border);
  border-radius: 5px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.bar-hull {
  background: linear-gradient(90deg, #4caf50, #66bb6a);
}

.bar-player {
  background: linear-gradient(90deg, #2196f3, #42a5f5);
}

.bar-enemy {
  background: linear-gradient(90deg, #e74c3c, #ff7043);
}

/* ============ DUEL HUD ============ */
.duel-bars {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px 8px;
  background: linear-gradient(180deg, rgba(10, 20, 35, 0.85) 0%, transparent 100%);
  flex-wrap: nowrap;
  overflow: hidden;
}

.duel-fighter {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
  max-width: 180px;
}

.duel-fighter:last-child {
  align-items: flex-end;
}

.fighter-name {
  font-family: var(--font-display);
  font-size: clamp(11px, 2.5vw, 16px);
  color: var(--parchment);
  letter-spacing: 0.05em;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.vs-badge {
  font-family: var(--font-display);
  font-size: clamp(16px, 4vw, 22px);
  color: var(--gold-bright);
  text-shadow: 0 0 10px rgba(212, 168, 67, 0.5);
  font-weight: 700;
  flex-shrink: 0;
}

.combo-display {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-display);
  font-size: clamp(20px, 5vw, 28px);
  color: var(--gold-bright);
  text-shadow: 0 0 15px rgba(212, 168, 67, 0.6), 2px 2px 0 rgba(0,0,0,0.5);
  z-index: 55;
  pointer-events: none;
  animation: comboPulse 0.3s ease;
  font-weight: 700;
}

@keyframes comboPulse {
  0% { transform: translateX(-50%) scale(1.3); }
  100% { transform: translateX(-50%) scale(1); }
}

.duel-prompt-text {
  position: fixed;
  top: 120px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-display);
  font-size: clamp(16px, 4vw, 24px);
  color: var(--parchment);
  text-shadow: 0 0 12px rgba(0,0,0,0.8);
  z-index: 55;
  pointer-events: none;
  letter-spacing: 0.1em;
  font-weight: 700;
}

.float-prompt {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--gold);
  border-radius: 8px;
  padding: 10px 20px;
  font-family: var(--font-display);
  font-size: 18px;
  color: var(--gold-bright);
  z-index: 55;
  pointer-events: none;
  animation: promptPulse 1s ease-in-out infinite;
  font-weight: 700;
}

@keyframes promptPulse {
  0%, 100% { opacity: 0.8; }
  50% { opacity: 1; }
}

/* Duel controls hint — visible during sword fights */
.duel-controls-hint {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 13px;
  color: var(--text-dim);
  z-index: 55;
  pointer-events: none;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.duel-controls-hint .ctrl-key {
  display: inline-block;
  background: rgba(212, 168, 67, 0.15);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 8px;
  font-family: ui-monospace, 'SF Mono', Consolas, monospace;
  font-size: 12px;
  color: var(--gold);
  min-width: 28px;
  text-align: center;
}

/* ============ RESULT ============ */
.result-stats {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px 24px;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 280px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 16px;
  color: var(--text);
}

.stat-val {
  font-family: var(--font-display);
  font-size: 22px;
  color: var(--gold-bright);
  font-weight: 700;
}

/* ============ TOUCH CONTROLS ============ */
.touch-controls {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 60;
  pointer-events: none;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 20px;
}

#sail-touch, #duel-touch {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  width: 100%;
}

.joystick-zone {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(212, 168, 67, 0.1);
  border: 2px solid rgba(212, 168, 67, 0.3);
  pointer-events: auto;
  touch-action: none;
  position: relative;
}

.joystick-zone::after {
  content: '';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(212, 168, 67, 0.3);
  border: 2px solid var(--gold);
}

.touch-btn {
  pointer-events: auto;
  border: 2px solid var(--gold);
  border-radius: 50%;
  font-family: var(--font-display);
  font-size: 16px;
  letter-spacing: 0.05em;
  color: var(--parchment);
  background: rgba(20, 35, 55, 0.8);
  touch-action: none;
  cursor: pointer;
  transition: transform 0.1s, background 0.1s;
  -webkit-tap-highlight-color: transparent;
  font-weight: 700;
}

.touch-btn:active {
  transform: scale(0.92);
  background: rgba(212, 168, 67, 0.3);
}

.touch-fire {
  width: 90px; height: 90px;
  background: rgba(192, 57, 43, 0.7);
  border-color: var(--crimson-bright);
  font-size: 18px;
}

.touch-move {
  width: 70px; height: 70px;
  font-size: 14px;
}

.touch-attack {
  width: 90px; height: 90px;
  background: rgba(192, 57, 43, 0.7);
  border-color: var(--crimson-bright);
  font-size: 16px;
}

.touch-parry {
  width: 80px; height: 80px;
  background: rgba(33, 150, 243, 0.6);
  border-color: #64b5f6;
  font-size: 15px;
}

.duel-move-group, .duel-action-group {
  display: flex;
  gap: 12px;
  align-items: flex-end;
}

/* ============ TRANSITION ============ */
#transition-overlay {
  position: fixed;
  inset: 0;
  background: #000;
  z-index: 200;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.33s ease;
}

/* ============ RESPONSIVE ============ */
@media (max-width: 480px) {
  .title-content { padding: 20px 16px; }
  .story { font-size: 14px; padding: 14px 16px; }
  .hud-stat { min-width: 80px; }
  .bar-wrap { width: 100px; }
  .duel-fighter { max-width: 140px; }
  .fighter-name { font-size: 11px; }
  .joystick-zone { width: 100px; height: 100px; }
  .touch-fire, .touch-attack { width: 76px; height: 76px; font-size: 14px; }
  .touch-move { width: 60px; height: 60px; font-size: 12px; }
  .touch-parry { width: 68px; height: 68px; font-size: 13px; }
  .duel-controls-hint { font-size: 11px; padding: 6px 12px; bottom: 10px; }
  .duel-controls-hint .ctrl-key { font-size: 10px; padding: 1px 5px; min-width: 22px; }
}

@media (min-width: 701px) and (pointer: fine) {
  .touch-controls { display: none !important; }
}


