/* ============================================================
   ARCHERY DUEL 3D — tournament archery UI
   Vanilla CSS · warm forest/gold HUD · responsive · touch-ready
   ============================================================ */

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

:root {
  --accent: #e0a835;
  --accent2: #ffd166;
  --accent3: #7a4a24;
  --forest: #2f5233;
  --danger: #ff3b3b;
  --ok: #4dffb0;
  --panel: rgba(16, 12, 4, 0.55);
  --font: "Courier New", ui-monospace, Menlo, Consolas, monospace;
}

html, body {
  height: 100%;
  background: #0a0704;
  color: #f5ecd8;
  font-family: var(--font);
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  user-select: none; -webkit-user-select: none;
  touch-action: none;
}

.game-wrap { position: fixed; inset: 0; width: 100%; height: 100%; overflow: hidden; }
#scene { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }

/* ---------- FX overlays ---------- */
.fx-flash { position: absolute; inset: 0; z-index: 4; pointer-events: none; opacity: 0; background: radial-gradient(circle, rgba(224,168,53,0.55), transparent 70%); }
.fx-flash.on { animation: flash .4s ease-out; }
@keyframes flash { from { opacity: 1; } to { opacity: 0; } }

.fx-lightning { position: absolute; inset: 0; z-index: 4; pointer-events: none; opacity: 0; background: #fff; }
.fx-lightning.on { animation: strike .25s ease-out; }
@keyframes strike { 0% { opacity: 0.85; } 40% { opacity: 0.1; } 60% { opacity: 0.6; } 100% { opacity: 0; } }

.fx-vignette { position: absolute; inset: 0; z-index: 3; pointer-events: none; opacity: 0; background: radial-gradient(ellipse at center, transparent 55%, rgba(10,20,10,0.55) 100%); transition: opacity .4s ease; }
.fx-vignette.on { opacity: 1; }

/* ---------- HUD ---------- */
.hud { position: absolute; inset: 0; z-index: 5; pointer-events: none; text-shadow: 0 0 6px rgba(224,168,53,0.4); }
.hud.hidden { display: none; }

.wind-box { position: absolute; top: 12px; left: 12px; z-index: 6; background: var(--panel); border: 2px solid rgba(224,168,53,0.5); border-radius: 12px; padding: 8px; display: flex; flex-direction: column; align-items: center; gap: 2px; backdrop-filter: blur(3px); }
.wind-box canvas { display: block; border-radius: 50%; background: #120d06; }
.wind-readout { display: flex; align-items: baseline; gap: 4px; margin-top: 2px; }
.wind-readout b { font-size: 18px; color: #fff; }
.wind-readout span { font-size: 10px; color: #d9c79a; }
.wind-label { font-size: 9px; letter-spacing: 1.5px; color: var(--accent2); margin-top: 2px; text-align: center; }

.info-box { position: absolute; top: 12px; right: 12px; z-index: 6; background: var(--panel); border: 1px solid rgba(224,168,53,0.4); border-radius: 10px; padding: 8px 14px; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.info-box .lbl { font-size: 10px; color: #d9c79a; letter-spacing: 1.5px; }
.info-box b { font-size: 20px; color: #fff; }

.hud-row { position: absolute; left: 0; right: 0; display: flex; justify-content: center; padding: 10px; }
.hud-mid { top: 48px; justify-content: flex-end; padding-right: 14px; }
.hud-bottom { bottom: 14px; left: 0; right: 0; display: flex; justify-content: space-between; align-items: flex-end; padding: 0 clamp(10px,3vw,26px); }

.icon-btn { pointer-events: auto; background: rgba(224,168,53,0.15); border: 1px solid rgba(224,168,53,0.4); color: #fff; border-radius: 8px; width: 38px; height: 34px; font-size: 15px; cursor: pointer; margin-left: 8px; transition: background .2s, transform .1s; }
.icon-btn:hover { background: rgba(224,168,53,0.3); }
.icon-btn:active { transform: scale(0.92); }

.turn-banner { position: absolute; top: 72px; left: 50%; transform: translateX(-50%); z-index: 6; font-size: clamp(14px,2.6vw,20px); font-weight: 800; letter-spacing: 3px; color: var(--accent2); text-shadow: 0 0 14px rgba(255,209,102,0.7); background: rgba(10,7,4,0.4); padding: 6px 18px; border-radius: 20px; border: 1px solid rgba(255,209,102,0.4); }

/* ---------- reticle ---------- */
.reticle { position: absolute; top: 50%; left: 50%; width: 30px; height: 30px; transform: translate(-50%, -50%); pointer-events: none; z-index: 5; transition: transform .05s linear; }
.r-h, .r-v { position: absolute; background: rgba(255,209,102,0.85); box-shadow: 0 0 6px rgba(255,209,102,0.8); }
.r-h { top: 50%; left: 4px; width: calc(100% - 8px); height: 2px; transform: translateY(-1px); }
.r-v { left: 50%; top: 4px; height: calc(100% - 8px); width: 2px; transform: translateX(-1px); }
.r-dot { position: absolute; top: 50%; left: 50%; width: 4px; height: 4px; border-radius: 50%; background: #ff3b3b; transform: translate(-50%, -50%); }

.score-popup { position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%) scale(0.6); z-index: 7; font-size: clamp(40px, 10vw, 80px); font-weight: 800; color: var(--accent2); text-shadow: 0 0 20px rgba(255,209,102,0.8), 0 0 50px rgba(0,0,0,0.8); opacity: 0; pointer-events: none; }
.score-popup.show { animation: popScore 1.3s ease-out; }
@keyframes popScore { 0% { opacity: 0; transform: translate(-50%, -50%) scale(0.4); } 25% { opacity: 1; transform: translate(-50%, -50%) scale(1.15); } 40% { transform: translate(-50%, -50%) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -60%) scale(1); } }

/* ---------- Scoreboard ---------- */
.scoreboard { position: absolute; bottom: 14px; left: 14px; z-index: 6; background: var(--panel); border: 1px solid rgba(224,168,53,0.4); border-radius: 12px; padding: 8px 10px; min-width: 170px; backdrop-filter: blur(3px); }
.sb-row { display: grid; grid-template-columns: 50px 1fr 1fr; gap: 4px; font-size: 11px; padding: 2px 0; align-items: center; }
.sb-row span { color: #d9c79a; }
.sb-row b { color: #fff; text-align: center; }
.sb-head { font-size: 9px; letter-spacing: 1px; color: var(--accent2); border-bottom: 1px solid rgba(224,168,53,0.3); padding-bottom: 3px; margin-bottom: 2px; }
.sb-total { border-top: 1px solid rgba(224,168,53,0.4); margin-top: 3px; padding-top: 4px; font-weight: 800; }
.sb-total b { color: var(--accent2); font-size: 14px; }

/* ---------- Bottom-right gauges ---------- */
.breath-box { display: flex; flex-direction: column; gap: 2px; background: var(--panel); border: 1px solid rgba(224,168,53,0.3); border-radius: 10px; padding: 6px 12px; transition: box-shadow .2s, border-color .2s; }
.breath-box.active { border-color: var(--ok); box-shadow: 0 0 14px rgba(77,255,176,0.4); }
.breath-box .lbl { font-size: 10px; color: var(--accent2); letter-spacing: 1px; }
.breath-box .hint-sm { font-size: 9px; color: #9c8a66; }

.power-box { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; min-width: 140px; }
.power-box .lbl { font-size: 10px; color: var(--accent); letter-spacing: 2px; }
.bar-track { width: clamp(120px, 26vw, 220px); height: 14px; background: rgba(255,255,255,0.12); border: 1px solid rgba(224,168,53,0.5); border-radius: 7px; overflow: hidden; }
.bar-fill { height: 100%; width: 0%; transition: width .05s linear; }
.bar-fill.power { background: linear-gradient(90deg, var(--forest), var(--accent), var(--danger)); }

/* ---------- Countdown ---------- */
.countdown { position: absolute; inset: 0; z-index: 9; display: flex; align-items: center; justify-content: center; pointer-events: none; }
.countdown.hidden { display: none; }
.countdown span { font-size: clamp(70px, 22vw, 180px); font-weight: 800; color: #fff; text-shadow: 0 0 24px var(--accent), 0 0 60px var(--accent3); animation: countPop .8s ease-out; }
@keyframes countPop { from { transform: scale(2.2); opacity: 0; } 40% { opacity: 1; } to { transform: scale(1); opacity: 0.15; } }

/* ---------- Overlays / panels ---------- */
.overlay { position: absolute; inset: 0; z-index: 10; display: flex; align-items: center; justify-content: center; background: rgba(10,7,4,0.84); backdrop-filter: blur(4px); padding: 16px; }
.overlay.hidden { display: none; }
.panel { text-align: center; padding: clamp(20px, 4vw, 40px); width: 100%; max-width: 480px; border: 2px solid rgba(224,168,53,0.35); border-radius: 18px; background: linear-gradient(160deg, rgba(122,74,36,0.22), rgba(47,82,51,0.18)); box-shadow: 0 0 48px rgba(224,168,53,0.2); }
.title { font-size: clamp(26px, 7vw, 48px); font-weight: 800; letter-spacing: 2px; color: #fff; text-shadow: 0 0 14px var(--accent), 0 0 34px var(--accent3); animation: flicker 4s infinite; }
.title.small { font-size: clamp(20px, 5.4vw, 34px); }
@keyframes flicker { 0%,92%,100%{opacity:1} 93%{opacity:.7} 95%{opacity:1} 97%{opacity:.8} }
.tagline { margin: 10px 0 20px; color: #d9c79a; font-size: clamp(12px, 2.4vw, 15px); letter-spacing: 0.5px; }

.menu-btns { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.btn { pointer-events: auto; padding: 13px 22px; font-family: var(--font); font-weight: 700; font-size: clamp(13px, 2.4vw, 16px); letter-spacing: 1.5px; color: #fff; background: rgba(255,255,255,0.06); border: 2px solid rgba(224,168,53,0.5); border-radius: 12px; cursor: pointer; transition: transform .12s, box-shadow .2s, background .2s; }
.btn:hover { background: rgba(224,168,53,0.15); box-shadow: 0 0 18px rgba(224,168,53,.35); }
.btn:active { transform: scale(0.96); }
.btn.primary { background: linear-gradient(135deg, #7a4a24, #e0a835); border-color: transparent; color: #1a1406; box-shadow: 0 6px 20px rgba(224,168,53,.45); }
.btn.ghost { border-color: rgba(217,199,154,0.35); color: #e7dcc2; font-size: clamp(12px,2.2vw,14px); padding: 10px 18px; }
.hint { margin-top: 12px; font-size: 11px; color: #8a7a5c; line-height: 1.6; }

.diff-row { display: flex; flex-direction: column; gap: 6px; align-items: center; margin-bottom: 14px; }
.diff-row .lbl { font-size: 10px; color: var(--accent2); letter-spacing: 2px; }
.seg { display: flex; gap: 4px; }
.seg button { pointer-events: auto; font-family: var(--font); font-size: 11px; padding: 7px 14px; border-radius: 8px; border: 1px solid rgba(224,168,53,0.4); background: rgba(255,255,255,0.05); color: #e7dcc2; cursor: pointer; }
.seg button.on { background: linear-gradient(135deg, #7a4a24, #e0a835); color: #1a1406; border-color: transparent; font-weight: 800; }

.help-list { text-align: left; list-style: none; display: flex; flex-direction: column; gap: 10px; margin: 10px 0 20px; font-size: clamp(12px, 2.1vw, 14px); color: #e7dcc2; line-height: 1.5; }

.result { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0 18px; }
.result div { background: rgba(255,255,255,0.05); border-radius: 10px; padding: 10px; display: flex; flex-direction: column; gap: 3px; }
.result span { font-size: 10px; color: #d9c79a; letter-spacing: 1px; }
.result b { font-size: clamp(15px,3vw,20px); color: var(--accent2); }
.new-high { color: var(--accent2); letter-spacing: 2px; margin-bottom: 6px; animation: flicker 1.1s infinite; }
#overScreen .btn, #pauseScreen .btn, #menuScreen .btn, #roundScreen .btn { width: 100%; }
#overScreen .btn + .btn, #pauseScreen .btn + .btn { margin-top: 8px; }

.scores-list { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 18px; }
.scores-list .row { display: flex; justify-content: space-between; background: rgba(255,255,255,0.05); padding: 9px 12px; border-radius: 8px; font-size: clamp(11px,2.2vw,14px); }
.scores-list .row span { color: #d9c79a; }
.scores-list .row b { color: #fff; }

/* ---------- Touch controls ---------- */
.touch { position: absolute; right: clamp(14px,4vw,28px); bottom: 110px; z-index: 8; }
.touch.hidden { display: none; }
.tbtn.breath { pointer-events: auto; width: 76px; height: 76px; border-radius: 50%; font-size: 11px; font-weight: 800; line-height: 1.3; color: #fff; background: radial-gradient(circle at 40% 35%, rgba(77,255,176,0.5), rgba(20,60,40,0.55)); border: 2px solid rgba(77,255,176,0.6); }
.tbtn.breath.active { background: radial-gradient(circle at 40% 35%, rgba(77,255,176,0.85), rgba(20,90,60,0.7)); }
@media (hover: none) and (pointer: coarse) { .touch.hidden { display: block; } }
body.touch-mode .reticle { opacity: .7; }

.back-home { position: absolute; left: 10px; top: 8px; z-index: 6; font-size: 11px; color: #8a7a5c; text-decoration: none; background: rgba(0,0,0,.3); padding: 4px 8px; border-radius: 6px; }
.back-home:hover { color: var(--accent); }
@media (max-width: 760px) { .scoreboard { transform: scale(0.84); transform-origin: bottom left; } .wind-box { transform: scale(0.84); transform-origin: top left; } }
@media (max-width: 620px) { .back-home { top: auto; bottom: 8px; left: 50%; transform: translateX(-50%); z-index: 2; } }
