:root { --acc: #f4c542; --txt: #f3f5ef; --panel: rgba(12, 32, 19, 0.94); --line: rgba(255,255,255,0.16); }
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #0c1d12; color: var(--txt); overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent; overscroll-behavior: none; -webkit-text-size-adjust: 100%; }
#cv { position: fixed; inset: 0; display: block; touch-action: none; }
#safe { position: fixed; inset: 0; visibility: hidden; pointer-events: none;
  padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); }
.hidden { display: none !important; }
button { font: inherit; color: inherit; min-height: 48px; min-width: 48px; border-radius: 14px; border: 2px solid var(--line);
  background: #1f4d2e; padding: 8px 16px; font-weight: 700; font-size: 16px; cursor: pointer; touch-action: manipulation; }
button:active { transform: scale(0.97); }
button.primary { background: var(--acc); color: #1d1d1d; border-color: #ffe08a; }
button:disabled { opacity: 0.45; cursor: default; }
button.small { min-height: 44px; padding: 6px 12px; font-size: 15px; }
button.sel { background: #e8eee5; color: #143019; border-color: #fff; }
h1 { margin: 0; font-size: clamp(30px, 7vh, 52px); letter-spacing: 0.5px; font-weight: 900; }
h2 { margin: 0; font-size: 22px; }
h3 { margin: 14px 0 4px; font-size: 17px; }
.screen { position: fixed; inset: 0; display: flex; overflow-y: auto; touch-action: pan-y; -webkit-overflow-scrolling: touch;
  padding: calc(env(safe-area-inset-top, 0px) + 8px) calc(env(safe-area-inset-right, 0px) + 12px) calc(env(safe-area-inset-bottom, 0px) + 8px) calc(env(safe-area-inset-left, 0px) + 12px);
  background: rgba(5, 16, 9, 0.6); }
.panel { margin: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; padding: 14px 18px; width: min(760px, 100%); box-shadow: 0 10px 40px rgba(0,0,0,0.5); }
.panel.narrow { width: min(380px, 100%); text-align: center; }
.title-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: center; background: rgba(12,32,19,0.86); }
.brand .sub { margin: 2px 0 8px; opacity: 0.75; }
.brand .tag { margin: 0; opacity: 0.85; }
.menu { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row > * { flex: 1 1 auto; }
.row.end { justify-content: flex-end; margin-top: 8px; }
.row.end > * { flex: 0 0 auto; }
.hdr { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 10px; margin-bottom: 8px; }
.hdr h2 { text-align: center; }
.sides { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.side { background: rgba(255,255,255,0.05); border-radius: 14px; padding: 8px; }
.side-label { font-size: 13px; text-transform: uppercase; letter-spacing: 1px; opacity: 0.75; text-align: center; }
.picker { display: grid; grid-template-columns: 48px 1fr 48px; align-items: center; gap: 4px; }
.arrow { padding: 0; font-size: 26px; }
.tname { text-align: center; font-weight: 800; font-size: 16px; }
.kit { display: flex; align-items: center; justify-content: center; gap: 10px; margin-top: 4px; }
.preview { width: 56px; height: 56px; }
.kit label { display: flex; flex-direction: column; align-items: center; font-size: 12px; gap: 2px; }
input[type=color] { width: 48px; height: 36px; border: 2px solid var(--line); border-radius: 10px; background: none; padding: 0; }
.opts { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 8px; }
.seg { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.seg > span { font-size: 13px; opacity: 0.75; margin-right: 4px; }
.seg button { min-height: 44px; padding: 4px 10px; font-size: 14px; border-radius: 12px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.toggle { min-width: 80px; }
.note { font-size: 13px; opacity: 0.75; margin: 6px 0; }
.big { font-size: 34px; font-weight: 900; margin: 8px 0; }
textarea { width: 100%; height: 90px; margin-top: 8px; background: #08160d; color: var(--txt); border: 1px solid var(--line); border-radius: 10px; font: 12px ui-monospace, Menlo, monospace; padding: 8px; -webkit-user-select: text; user-select: text; touch-action: auto; }
.filebtn { position: relative; overflow: hidden; display: inline-flex; align-items: center; justify-content: center; min-height: 48px; border-radius: 14px; border: 2px solid var(--line); background: #1f4d2e; padding: 8px 16px; font-weight: 700; }
.filebtn input { position: absolute; inset: 0; opacity: 0; }
.help { margin: 0; padding-left: 20px; line-height: 1.45; }
.help li { margin-bottom: 6px; }
table.stats { width: 100%; border-collapse: collapse; }
table.stats td { padding: 6px 4px; border-bottom: 1px solid var(--line); }
table.stats td:last-child { text-align: right; font-weight: 800; }

#hud { position: fixed; inset: 0; pointer-events: none; }
#scoreboard { pointer-events: auto; position: absolute; top: env(safe-area-inset-top, 0px); left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 7px; background: rgba(0,0,0,0.55); padding: 2px 14px; min-height: 30px; border: 0; border-radius: 0 0 14px 14px;
  font-weight: 800; font-size: 14px; white-space: nowrap; }
#scoreboard:active { transform: translateX(-50%) scale(0.97); }
#scoreboard .pz { font-size: 11px; opacity: 0.85; margin-right: 4px; padding: 3px 6px; border-radius: 6px; background: rgba(255,255,255,0.14); }
#score { font-size: 16px; padding: 0 2px; }
#clock { margin-left: 6px; opacity: 0.85; font-variant-numeric: tabular-nums; font-weight: 600; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; border: 2px solid rgba(255,255,255,0.6); }
#turnBar { position: absolute; bottom: env(safe-area-inset-bottom, 0px); left: 50%; transform: translateX(-50%); display: flex; align-items: flex-end; gap: 8px; }
#turnBanner { background: rgba(0,0,0,0.55); padding: 3px 14px; border-radius: 12px 12px 0 0; font-size: 13px; font-weight: 700; white-space: nowrap; }
#turnBanner:empty { display: none; }
#skipBtn { pointer-events: auto; min-height: 40px; padding: 4px 14px; font-size: 14px; background: var(--acc); color: #1d1d1d; border-color: #ffe08a; border-radius: 12px 12px 0 0; }
#toast { position: fixed; left: 50%; top: 42%; transform: translate(-50%, -50%) scale(0.9); pointer-events: none; opacity: 0;
  font-size: clamp(22px, 7vh, 48px); font-weight: 900; text-shadow: 0 3px 10px rgba(0,0,0,0.7); transition: opacity 0.25s, transform 0.25s; text-align: center; white-space: nowrap; }
#toast.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
#toast.goal { color: var(--acc); font-size: clamp(40px, 14vh, 96px); }
#rotate { display: none; position: fixed; inset: 0; background: #0c1d12; z-index: 50; align-items: center; justify-content: center; text-align: center; font-size: 22px; font-weight: 700; padding: 30px; line-height: 1.6; }
@media (orientation: portrait) and (max-width: 600px) { #rotate { display: flex; } }
@media (max-height: 430px) {
  .panel { padding: 10px 14px; }
  .title-panel { gap: 12px; }
  .brand .tag { display: none; }
  .menu { gap: 6px; }
  .menu button { min-height: 46px; padding: 6px 12px; }
}
@media (max-width: 560px) { .title-panel { grid-template-columns: 1fr; } }
