/* Eolle (얼레) - Mobile-First Korean Kite Duel Stylesheet
   390x844 baseline, supports 320px narrow screens and 480px centered desktop column. */

:root {
  --bg-outer: #0d1624;
  --bg-col: #18273a;
  --surface: rgba(16, 26, 42, 0.86);
  --surface-solid: #162235;
  --surface-soft: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 245, 224, 0.18);
  --ink: #faf5e8;
  --ink-dim: rgba(250, 245, 232, 0.72);
  --accent: #f4b942;
  --accent-ink: #1b150c;
  --player: #e84a3c;
  --ai: #32b8a8;
  --danger: #ff5454;
  --safe: #57cc99;
  --cut: #f4b942;
  --kit-bg: #121d2e;
  --kit-sheet: #192438;
  --kit-fg: #faf5e8;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at 50% 20%, #1d314d 0%, var(--bg-outer) 72%);
  color: var(--ink);
  font-family: 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans KR', system-ui, -apple-system, sans-serif;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
}

.app {
  position: relative;
  width: 100%;
  max-width: 480px;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--bg-col);
  overflow: hidden;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.5);
}

/* --- Top HUD --- */
.hud-top {
  position: relative;
  z-index: 20;
  flex: 0 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) 10px 6px;
  background: linear-gradient(180deg, rgba(12, 20, 34, 0.88) 0%, rgba(12, 20, 34, 0.56) 100%);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(6px);
}

.hud-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}

.hud-row-main {
  /* Leave clear room for #kit-gear at top-right */
  padding-right: 52px;
  min-height: 44px;
}

.hud-row-series {
  margin-top: 4px;
  min-height: 24px;
}

.stage-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  min-width: 44px;
  padding: 4px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.09);
  color: var(--ink);
  font: 700 13px/1.1 inherit;
  cursor: pointer;
  touch-action: manipulation;
  max-width: 55%;
  overflow: hidden;
}

.stage-pill:active {
  transform: scale(0.97);
}

.stage-badge {
  background: var(--accent);
  color: var(--accent-ink);
  padding: 2px 6px;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 800;
  flex-shrink: 0;
}

.stage-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.hud-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.score-pill {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  padding: 3px 8px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.12);
  line-height: 1.1;
}

.score-label {
  font-size: 10px;
  color: var(--ink-dim);
}

.score-pill strong {
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  color: var(--accent);
}

.icon-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(15, 22, 34, 0.72);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: manipulation;
}

.icon-btn:active {
  transform: scale(0.95);
}

.icon-btn.muted {
  color: var(--ink-dim);
  opacity: 0.75;
}

.series-side {
  display: flex;
  align-items: center;
  gap: 6px;
}

.side-tag {
  font-size: 11px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 99px;
}

.player-tag {
  background: rgba(232, 74, 60, 0.25);
  border: 1px solid rgba(232, 74, 60, 0.65);
  color: #ffd3ce;
}

.ai-tag {
  background: rgba(50, 184, 168, 0.22);
  border: 1px solid rgba(50, 184, 168, 0.65);
  color: #c5f7f0;
  max-width: 82px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pips {
  display: flex;
  gap: 5px;
}

.pip {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.42);
  background: rgba(255, 255, 255, 0.08);
  transition: transform 0.22s ease, background 0.22s ease;
}

.series-player .pip.won {
  background: #ff6b5b;
  border-color: #fff2cc;
  box-shadow: 0 0 8px rgba(255, 107, 91, 0.8);
  transform: scale(1.12);
}

.series-ai .pip.won {
  background: #3ee0cb;
  border-color: #e6fffc;
  box-shadow: 0 0 8px rgba(62, 224, 203, 0.8);
  transform: scale(1.12);
}

.round-center {
  display: flex;
  align-items: center;
  gap: 6px;
  font-variant-numeric: tabular-nums;
}

.round-tag {
  font-size: 11px;
  font-weight: 800;
  color: var(--ink-dim);
}

.timer-val {
  font-size: 14px;
  font-weight: 800;
  color: var(--ink);
  min-width: 38px;
  text-align: center;
}

/* --- Sky Canvas Arena --- */
.sky-wrap {
  position: relative;
  flex: 1 1 auto;
  min-height: 220px;
  width: 100%;
  overflow: hidden;
  touch-action: none;
}

.sky-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.sky-callout {
  position: absolute;
  left: 50%;
  top: 76px;
  transform: translateX(-50%) scale(0.92);
  padding: 5px 14px;
  border-radius: 99px;
  background: rgba(14, 22, 36, 0.78);
  border: 1px solid rgba(244, 185, 66, 0.6);
  color: #fff6dc;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.02em;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  white-space: nowrap;
  z-index: 10;
}

.sky-callout.show {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

.sky-callout.danger {
  border-color: rgba(255, 84, 84, 0.9);
  background: rgba(120, 18, 24, 0.85);
  color: #ffe3e3;
}

.sky-callout.cut {
  border-color: #ffe066;
  background: rgba(125, 78, 8, 0.88);
  color: #fff7d1;
}

/* --- Bottom Control Deck --- */
.control-deck {
  position: relative;
  z-index: 20;
  flex: 0 0 auto;
  padding: 8px 12px calc(env(safe-area-inset-bottom, 0px) + 30px);
  background: linear-gradient(180deg, rgba(22, 32, 48, 0.94) 0%, #101826 100%);
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Integrity clash strip */
.integrity-strip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.34);
  border: 1px solid rgba(244, 185, 66, 0.36);
  font-size: 11px;
  font-weight: 700;
}

.integrity-strip[hidden] {
  display: none;
}

.int-side {
  flex: 1 1 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.int-vs {
  color: var(--accent);
  font-weight: 800;
  font-size: 11px;
  white-space: nowrap;
}

.int-track {
  flex: 1 1 auto;
  height: 7px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.14);
  overflow: hidden;
}

.int-fill {
  display: block;
  height: 100%;
  width: 100%;
  border-radius: 99px;
  transition: width 0.08s linear;
}

.int-fill.player {
  background: linear-gradient(90deg, #ff6b5b, #f4b942);
}

.int-fill.ai {
  background: linear-gradient(90deg, #2a9d8f, #64dfdf);
}

/* Tension Gauge */
.tension-box {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tension-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  font-size: 11.5px;
}

.tension-status {
  font-weight: 800;
  color: var(--ink);
}

.tension-status.fall { color: #ff8787; }
.tension-status.cut { color: #ffd43b; }
.tension-status.snap { color: #ff5454; }

.wind-charge-pill {
  padding: 1px 8px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-size: 10.5px;
  font-weight: 700;
  color: var(--ink-dim);
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}

.wind-charge-pill.hot {
  background: rgba(244, 185, 66, 0.24);
  border-color: rgba(244, 185, 66, 0.8);
  color: #ffe8a3;
}

.spool-readout {
  font-variant-numeric: tabular-nums;
  color: var(--ink-dim);
}

.spool-readout strong {
  color: var(--ink);
}

.tension-bar {
  position: relative;
  height: 16px;
  border-radius: 99px;
  background: rgba(0, 0, 0, 0.46);
  border: 1px solid rgba(255, 255, 255, 0.2);
  overflow: hidden;
  display: flex;
}

.tz {
  height: 100%;
  opacity: 0.42;
}
.tz-fall { width: 18%; background: linear-gradient(90deg, #b82929, #e64949); }
.tz-safe { width: 36%; background: linear-gradient(90deg, #3b6ea5, #4da89b); }
.tz-cut  { width: 33%; background: linear-gradient(90deg, #e0a82e, #ffd43b); opacity: 0.62; }
.tz-snap { width: 13%; background: linear-gradient(90deg, #e03131, #ff1e1e); }

.tension-fill {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 48%;
  background: rgba(255, 255, 255, 0.22);
  pointer-events: none;
}

.tension-needle {
  position: absolute;
  top: -1px;
  bottom: -1px;
  left: 48%;
  width: 6px;
  margin-left: -3px;
  border-radius: 3px;
  background: #ffffff;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.95), 0 0 3px #000;
  pointer-events: none;
}

.tension-bar.danger {
  border-color: #ff5454;
  box-shadow: 0 0 12px rgba(255, 64, 64, 0.7);
}

.tension-bar.cutting {
  border-color: #ffd43b;
  box-shadow: 0 0 10px rgba(244, 185, 66, 0.55);
}

.tension-labels {
  display: flex;
  font-size: 10px;
  color: var(--ink-dim);
  line-height: 1;
}
.tl-fall { width: 18%; text-align: left; color: #ff9c9c; }
.tl-safe { width: 36%; text-align: center; }
.tl-cut  { width: 33%; text-align: center; color: #ffe07d; font-weight: 700; }
.tl-snap { width: 13%; text-align: right; color: #ff8080; }

/* Eolle Drag Control */
.reel-zone {
  position: relative;
  touch-action: none;
  cursor: grab;
  outline: none;
}

.reel-zone.dragging {
  cursor: grabbing;
}

.reel-track {
  position: relative;
  height: 90px;
  border-radius: 18px;
  background:
    radial-gradient(ellipse at 50% 50%, rgba(215, 168, 110, 0.14), rgba(0, 0, 0, 0.34) 72%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.03) 0 8px, transparent 8px 18px);
  border: 1.5px solid rgba(224, 184, 126, 0.34);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  overflow: hidden;
}

.reel-zone.dragging .reel-track {
  border-color: rgba(244, 185, 66, 0.75);
}

.reel-wing {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 44px;
  min-width: 56px;
  font-weight: 800;
  font-size: 13px;
  color: var(--ink-dim);
  pointer-events: none;
  transition: color 0.12s ease, transform 0.12s ease;
  z-index: 2;
}

.reel-wing.right {
  justify-content: flex-end;
}

.reel-wing.active-left {
  color: #74d9ff;
  transform: translateX(-3px);
}

.reel-wing.active-right {
  color: #ffd43b;
  transform: translateX(3px);
}

.wing-arrow {
  font-size: 15px;
}

.reel-handle {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 3;
  filter: drop-shadow(0 6px 10px rgba(0, 0, 0, 0.55));
  will-change: transform;
}

.eolle-svg {
  display: block;
  width: 112px;
  height: 78px;
}

.reel-hint {
  margin-top: 4px;
  text-align: center;
  font-size: 11px;
  color: var(--ink-dim);
}

/* --- Overlays & Modals --- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: calc(env(safe-area-inset-top, 0px) + 56px) 14px calc(env(safe-area-inset-bottom, 0px) + 34px);
  background: rgba(8, 14, 24, 0.72);
  backdrop-filter: blur(5px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
}

.overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.overlay-float {
  background: rgba(8, 14, 24, 0.36);
  backdrop-filter: blur(2px);
}

.modal-card {
  width: 100%;
  max-width: 400px;
  max-height: 100%;
  overflow-y: auto;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(25, 38, 58, 0.96) 0%, rgba(16, 24, 38, 0.98) 100%);
  border: 1px solid rgba(250, 232, 194, 0.24);
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.55);
  padding: 18px 16px;
  text-align: center;
}

.emblem-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 2px;
}

.game-title {
  margin: 0;
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: #fff4d6;
  text-shadow: 0 3px 12px rgba(244, 185, 66, 0.3);
}

.game-sub {
  margin: 5px 0 12px;
  font-size: 13px;
  line-height: 1.4;
  color: var(--ink-dim);
}

.best-strip {
  display: flex;
  justify-content: center;
  gap: 16px;
  padding: 7px 12px;
  margin-bottom: 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 12px;
  color: var(--ink-dim);
}

.best-strip strong {
  color: var(--accent);
  margin-left: 4px;
}

.stage-section {
  text-align: left;
  margin-bottom: 14px;
}

.stage-section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink-dim);
  margin-bottom: 8px;
}

.stage-preview-rival {
  color: #9be7d8;
}

.stage-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.stage-chip {
  position: relative;
  min-height: 50px;
  padding: 6px 4px;
  border-radius: 12px;
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  touch-action: manipulation;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.12s ease;
}

.stage-chip:active {
  transform: scale(0.96);
}

.stage-chip.selected {
  border-color: var(--accent);
  background: rgba(244, 185, 66, 0.22);
  box-shadow: 0 0 12px rgba(244, 185, 66, 0.3);
}

.stage-chip .sc-num {
  font-size: 11px;
  font-weight: 800;
  color: var(--accent);
}

.stage-chip .sc-name {
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
}

.stage-chip .sc-star {
  position: absolute;
  top: 3px;
  right: 4px;
  font-size: 10px;
  color: #ffd43b;
}

.stage-desc {
  margin: 8px 0 0;
  padding: 7px 10px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.25);
  font-size: 12px;
  line-height: 1.4;
  color: var(--ink-dim);
}

/* Result & Match Cards */
.result-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 800;
  margin-bottom: 6px;
}

.result-badge.win {
  background: rgba(244, 185, 66, 0.25);
  border: 1px solid rgba(244, 185, 66, 0.75);
  color: #ffe599;
}

.result-badge.lose {
  background: rgba(255, 84, 84, 0.22);
  border: 1px solid rgba(255, 84, 84, 0.7);
  color: #ffc2c2;
}

.round-heading, .match-heading {
  margin: 2px 0 6px;
  font-size: 22px;
  font-weight: 900;
  color: #fff6e0;
}

.round-sub {
  margin: 0 0 12px;
  font-size: 13px;
  color: var(--ink-dim);
}

.score-breakdown {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 10px 12px;
  margin-bottom: 10px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.3);
  font-size: 12.5px;
}

.sb-row {
  display: flex;
  justify-content: space-between;
  color: var(--ink-dim);
}

.sb-row strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.sb-row.sb-total {
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  padding-top: 5px;
  margin-top: 2px;
  font-weight: 800;
  color: var(--accent);
}

.sb-row.sb-total strong {
  color: var(--accent);
}

.round-series-text {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 14px;
}

.match-score-big {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 12px;
  margin: 10px 0;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(244, 185, 66, 0.28);
}

.match-score-label {
  font-size: 12px;
  color: var(--ink-dim);
}

.match-score-big strong {
  font-size: 32px;
  font-weight: 900;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.new-best-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 99px;
  background: #ff6b5b;
  color: #fff;
  font-size: 11px;
  font-weight: 800;
}

.match-rounds-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin-bottom: 14px;
}

.mr-chip {
  padding: 4px 8px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
}

.mr-chip.win { border-color: rgba(244, 185, 66, 0.65); color: #ffe599; }
.mr-chip.lose { border-color: rgba(255, 107, 91, 0.55); color: #ffc2c2; }

/* Buttons (all >= 44px touch targets) */
.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.match-actions {
  gap: 8px;
}

.btn-primary, .btn-secondary, .btn-ghost {
  width: 100%;
  min-height: 48px;
  padding: 10px 16px;
  border-radius: 14px;
  font: 800 15px/1.2 inherit;
  cursor: pointer;
  touch-action: manipulation;
  border: none;
  transition: transform 0.1s ease, filter 0.15s ease;
}

.btn-primary:active, .btn-secondary:active, .btn-ghost:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(180deg, #ffd166 0%, #e5a324 100%);
  color: #1f1608;
  box-shadow: 0 6px 18px rgba(229, 163, 36, 0.35);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.13);
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.24);
}

.btn-ghost {
  min-height: 44px;
  background: transparent;
  color: var(--ink-dim);
  border: 1px solid rgba(255, 255, 255, 0.14);
  font-weight: 700;
  font-size: 14px;
}

/* Narrow 320px screen adjustments */
@media (max-width: 350px) {
  .hud-top { padding: calc(env(safe-area-inset-top, 0px) + 6px) 8px 5px; }
  .hud-row-main { padding-right: 48px; }
  .stage-pill { padding: 4px 7px; font-size: 12px; gap: 4px; }
  .score-pill { padding: 2px 6px; }
  .score-pill strong { font-size: 13px; }
  .control-deck { padding: 6px 8px calc(env(safe-area-inset-bottom, 0px) + 28px); gap: 6px; }
  .reel-track { height: 82px; padding: 0 8px; }
  .eolle-svg { width: 96px; height: 68px; }
  .reel-wing { font-size: 12px; min-width: 46px; }
  .stage-grid { gap: 4px; }
  .stage-chip { min-height: 46px; }
  .stage-chip .sc-name { font-size: 10px; }
  .modal-card { padding: 14px 12px; }
  .game-title { font-size: 28px; }
}
