:root {
  --brass: #c9a45c;
  --brass-hi: #e6c98a;
  --brass-dim: #8a6f3c;
  --paper: #efe6d2;
  --panel: rgba(14, 10, 7, 0.78);
  --panel-edge: rgba(201, 164, 92, 0.35);
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #000;
  color: var(--paper);
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  -webkit-font-smoothing: antialiased;
  user-select: none;
}
#gfx { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; outline: none; }
.hidden { display: none !important; }

/* ------------------------------------------------------------------ boot */
#boot {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, #1a140c 0%, #050403 70%);
  transition: opacity 1.4s ease; z-index: 50;
}
#boot.fade { opacity: 0; pointer-events: none; }
.boot-inner { text-align: center; }
.brand { font-size: 46px; letter-spacing: 0.35em; color: var(--brass); text-shadow: 0 0 28px rgba(201,164,92,0.25); padding-left: 0.35em; }
.sub { margin-top: 8px; font-style: italic; letter-spacing: 0.2em; opacity: 0.72; }
#boot-status { margin-top: 36px; font-size: 14px; letter-spacing: 0.12em; opacity: 0.8; min-height: 1.2em; }
.bar { margin: 14px auto 0; width: 300px; height: 2px; background: rgba(255,255,255,0.08); }
#boot-bar { height: 100%; width: 0%; background: var(--brass); transition: width 0.4s ease; }
.error { color: #ff8a7a; max-width: 560px; line-height: 1.5; margin: 0 auto; }

/* ------------------------------------------------------------------ menus */
.panel-screen {
  position: fixed; inset: 0; display: flex; align-items: center; justify-content: flex-start;
  z-index: 20; pointer-events: auto;
  background: linear-gradient(90deg, rgba(5,4,3,0.82) 0%, rgba(5,4,3,0.45) 45%, rgba(5,4,3,0) 75%);
}
#pause, #settings, #controls, #gameover { justify-content: center; background: rgba(4,3,2,0.55); backdrop-filter: blur(3px); }
.menu-inner { margin-left: 8vw; max-width: 520px; }
.menu-inner.small {
  margin: 0; max-width: 620px; padding: 34px 42px; background: var(--panel);
  border: 1px solid var(--panel-edge); box-shadow: 0 20px 60px rgba(0,0,0,0.6);
}
.menu-inner .brand { font-size: 52px; white-space: nowrap; }
.menu-title { font-size: 22px; letter-spacing: 0.22em; color: var(--brass); text-transform: uppercase; margin-bottom: 18px; }
.menu-buttons { display: flex; flex-direction: column; gap: 10px; margin-top: 34px; min-width: 340px; }
.menu-inner.small .menu-buttons { margin-top: 20px; }
button {
  font-family: inherit; font-size: 18px; letter-spacing: 0.08em; text-align: left;
  color: var(--paper); background: rgba(20, 14, 9, 0.6);
  border: 1px solid var(--panel-edge); padding: 13px 20px; cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.15s, color 0.15s;
}
button:hover { background: rgba(201,164,92,0.16); border-color: var(--brass); color: #fff; transform: translateX(4px); }
button.secondary { font-size: 15px; opacity: 0.85; padding: 10px 20px; }
button small { opacity: 0.6; font-style: italic; letter-spacing: 0.02em; font-size: 14px; }
.join-row { display: flex; gap: 10px; }
.join-row input {
  width: 140px; font-family: inherit; font-size: 20px; letter-spacing: 0.3em; text-transform: uppercase; text-align: center;
  background: rgba(0,0,0,0.5); color: var(--paper); border: 1px solid var(--panel-edge); padding: 10px;
}
.join-row button { flex: 1; }
#online-status { min-height: 1.4em; font-size: 15px; line-height: 1.6; opacity: 0.9; }
#online-status code { color: var(--brass-hi); font-size: 22px; letter-spacing: 0.25em; }
#online-status a { color: var(--brass-hi); }

.settings-grid { display: grid; grid-template-columns: 1fr 220px; gap: 12px 24px; align-items: center; font-size: 15px; }
.settings-grid select, .settings-grid input[type=range] { width: 100%; accent-color: var(--brass); }
.settings-grid select { font-family: inherit; background: #1a120b; color: var(--paper); border: 1px solid var(--panel-edge); padding: 5px; }
.controls-grid { display: grid; grid-template-columns: 170px 1fr; gap: 8px 18px; font-size: 15px; line-height: 1.35; }
.controls-grid b { color: var(--brass-hi); font-weight: normal; letter-spacing: 0.05em; }
.rules { font-size: 14px; line-height: 1.55; opacity: 0.8; margin-top: 18px; }
#go-sub { font-size: 16px; opacity: 0.85; }

/* ------------------------------------------------------------------ HUD */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }
#scoreboard {
  position: absolute; top: 18px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: stretch; gap: 0;
  background: linear-gradient(180deg, rgba(18,12,8,0.82), rgba(10,7,5,0.72));
  border: 1px solid var(--panel-edge); box-shadow: 0 8px 30px rgba(0,0,0,0.5);
}
#scoreboard .player { padding: 9px 18px; min-width: 250px; transition: background 0.3s; }
#scoreboard .player.active { background: rgba(201,164,92,0.14); }
#scoreboard .player.right { text-align: right; }
#scoreboard .name { font-size: 16px; letter-spacing: 0.1em; }
#scoreboard .name .grp { font-size: 12px; opacity: 0.7; font-style: italic; letter-spacing: 0.04em; margin: 0 6px; }
#scoreboard .balls { display: flex; gap: 4px; margin-top: 6px; min-height: 18px; }
#scoreboard .right .balls { justify-content: flex-end; }
#turn-ind { width: 2px; background: var(--panel-edge); }
.mini {
  width: 18px; height: 18px; border-radius: 50%; position: relative; overflow: hidden;
  box-shadow: inset -2px -3px 4px rgba(0,0,0,0.45), inset 2px 2px 3px rgba(255,255,255,0.25);
  font: bold 8px Helvetica, Arial, sans-serif; color: #111; display: flex; align-items: center; justify-content: center;
}
.mini::after { content: attr(data-n); background: #f4efe4; border-radius: 50%; width: 9px; height: 9px; line-height: 9px; text-align: center; position: relative; z-index: 2; }
.mini.stripe::before { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, #f4efe4 0 22%, transparent 22% 78%, #f4efe4 78%); z-index: 1; }
.mini.gone { opacity: 0.18; }
#toast {
  position: absolute; top: 96px; left: 50%; transform: translateX(-50%);
  font-size: 24px; letter-spacing: 0.08em; text-align: center; white-space: nowrap;
  text-shadow: 0 2px 12px rgba(0,0,0,0.9), 0 0 2px rgba(0,0,0,0.9);
  opacity: 0; transition: opacity 0.4s;
}
#toast.show { opacity: 1; }
#crosshair { position: absolute; left: 50%; top: 50%; width: 4px; height: 4px; margin: -2px 0 0 -2px; border-radius: 50%; background: rgba(255,248,230,0.75); box-shadow: 0 0 3px rgba(0,0,0,0.8); }
#prompt {
  position: absolute; bottom: 12%; left: 50%; transform: translateX(-50%);
  font-size: 17px; letter-spacing: 0.06em; text-shadow: 0 2px 8px rgba(0,0,0,0.95); opacity: 0.92; white-space: nowrap;
}
#stance-ui { position: absolute; inset: 0; transition: opacity 0.2s; }
#stance-ui.dim { opacity: 0.12; }
#spin-widget { position: absolute; right: 36px; bottom: 36px; text-align: center; }
#spin-widget .ball {
  width: 92px; height: 92px; border-radius: 50%; position: relative;
  background: radial-gradient(circle at 38% 32%, #fffdf6 0%, #e9e3d4 45%, #9d978a 100%);
  box-shadow: 0 6px 20px rgba(0,0,0,0.6);
}
#spin-widget .ball::before { content: ""; position: absolute; inset: 22%; border-radius: 50%; border: 1px dashed rgba(160,40,30,0.35); }
#spin-widget .dot { position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: #2a63b8; box-shadow: 0 0 0 2px rgba(255,255,255,0.8), 0 0 6px rgba(0,0,0,0.6); left: 50%; top: 50%; }
#spin-widget .dot.miscue { background: #c22; }
.label { margin-top: 7px; font-size: 11px; letter-spacing: 0.3em; opacity: 0.7; }
#elev { font-size: 13px; opacity: 0.85; margin-top: 2px; }
#power-widget { position: absolute; right: 150px; bottom: 36px; text-align: center; }
#power-widget .track { width: 12px; height: 120px; margin: 0 auto; background: rgba(0,0,0,0.55); border: 1px solid var(--panel-edge); position: relative; }
#power-widget .fill { position: absolute; left: 0; right: 0; bottom: 0; height: 0%; background: linear-gradient(0deg, #6a8f3a, #d8b24a 60%, #c2402c); background-size: 100% 120px; background-position: bottom; }
#power-pct { font-size: 12px; margin-top: 2px; min-height: 15px; opacity: 0.85; font-variant-numeric: tabular-nums; }
#call-ui { position: absolute; inset: 0; pointer-events: none; }
#call-title { position: absolute; top: 138px; left: 50%; transform: translateX(-50%); width: min(92vw, 720px); text-align: center; font-size: 22px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--brass-hi); text-shadow: 0 2px 10px #000; }
#call-labels .pk { position: absolute; transform: translate(-50%, -50%); width: 34px; height: 34px; border-radius: 50%; border: 2px solid rgba(244, 226, 170, 0.75); background: rgba(10, 8, 6, 0.6); color: #f4e8c8; font-size: 17px; line-height: 30px; text-align: center; transition: transform 0.12s, background 0.12s; }
#call-labels .pk.hover { background: rgba(216, 178, 74, 0.92); color: #140f08; border-color: #fff3cf; transform: translate(-50%, -50%) scale(1.3); }
#call-pointer { position: absolute; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: #fff6dc; box-shadow: 0 0 0 2px rgba(0,0,0,0.6), 0 0 12px rgba(255, 230, 170, 0.8); }
#stance-help {
  position: absolute; left: 50%; bottom: 22px; transform: translateX(-50%);
  display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; max-width: 70vw;
  font-size: 12px; letter-spacing: 0.04em; opacity: 0.62; text-shadow: 0 1px 4px #000;
}
#stance-help b { color: var(--brass-hi); font-weight: normal; }
#thinking { position: absolute; top: 132px; left: 50%; transform: translateX(-50%); font-style: italic; opacity: 0.8; letter-spacing: 0.1em; text-shadow: 0 2px 8px #000; }
#thinking span { animation: blink 1.2s infinite; }
#thinking span:nth-child(2) { animation-delay: 0.2s; }
#thinking span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 100% { opacity: 0.2; } 50% { opacity: 1; } }
#click-to-play {
  position: fixed; left: 50%; top: 58%; transform: translateX(-50%); z-index: 30;
  font-size: 18px; letter-spacing: 0.15em; padding: 12px 24px; background: var(--panel); border: 1px solid var(--panel-edge);
}

#credits { justify-content: center; background: rgba(4,3,2,0.6); backdrop-filter: blur(3px); }
.credits { max-height: 86vh; overflow-y: auto; font-size: 14px; line-height: 1.55; user-select: text; }
.credits h4 { margin: 16px 0 4px; color: var(--brass-hi); font-weight: normal; letter-spacing: 0.12em; text-transform: uppercase; font-size: 12px; }
.credits p { margin: 4px 0; opacity: 0.88; }
.credits a { color: var(--brass-hi); }

/* Trailer capture */
body.capturing #click-to-play, body.capturing #crosshair { display: none !important; }
body.cap-clean #hud { display: none !important; }
body.cap-clean .panel-screen, body.cap-clean #toast { display: none !important; }
