:root {
  --bg: #1c2a23;
  --bg-2: #1f2f27;
  --card: #243731;
  --card-deep: #0f1a15;
  --line: #34473f;
  --text: #e9efe9;
  --muted: #9fb0a6;
  --cream: #f6e7b8;
  --gold: #c9963a;
  --yellow: #f5c518;
  --yellow-deep: #b78d0b;
  --orange: #e8a33d;
  --red: #d9302c;
  --red-deep: #9c1f1c;
  --green: #7ed957;
  --lime: #f2d233;
  --amber: #f0802f;
  --hot: #e8433a;
  --radius: 18px;
}
* { box-sizing: border-box; }
html { color-scheme: dark; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  color: var(--text);
  background:
    repeating-linear-gradient(135deg, rgba(255,255,255,.018) 0 2px, transparent 2px 9px),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) 16px max(24px, env(safe-area-inset-bottom));
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.app { max-width: 360px; margin: 0 auto; }

/* ---------- hero ---------- */
.hero { text-align: center; margin-top: 8px; }
.logo {
  font-family: Bungee, Inter, sans-serif;
  font-size: 40px; line-height: 1; letter-spacing: 1px; margin: 0;
  color: var(--cream);
  text-shadow: 0 2px 0 #d9822b, 0 4px 0 #a55f1c, 0 6px 10px rgba(0,0,0,.45);
}
.tagline { color: var(--muted); margin: 10px 0 16px; }

/* ---------- tabs ---------- */
.tabs {
  display: flex; padding: 4px; gap: 2px;
  background: #101a15; border: 1.5px solid var(--line); border-radius: 999px;
}
.tab {
  flex: 1; border: 0; background: transparent; color: var(--muted);
  font-weight: 700; padding: 9px 6px; border-radius: 999px; font-size: 13px;
  transition: background .15s, color .15s;
}
.tab.active { background: var(--gold); color: #1a1408; }

.view { margin-top: 20px; }
.section-intro { color: var(--muted); text-align: center; margin: 0 0 14px; line-height: 1.45; }

/* ---------- card ---------- */
.card {
  background: var(--card); border-radius: var(--radius); padding: 14px;
  border: 2px solid var(--orange); box-shadow: 0 10px 30px rgba(0,0,0,.35);
}
.form-card { border-color: var(--line); }
.meter-card { padding: 16px; }

.score-box {
  background: var(--card-deep); border-radius: 12px; padding: 10px 14px;
  display: flex; align-items: baseline; justify-content: center; gap: 6px;
  border: 1px solid #06100b;
}
.score-num {
  font-family: Bungee, Inter, sans-serif; font-size: 40px; color: var(--yellow);
  text-shadow: 0 0 18px rgba(245,197,24,.35); min-width: 1.2em; text-align: right;
}
.score-den { color: var(--muted); font-size: 13px; }

/* ---------- meter ---------- */
.meter { display: grid; grid-template-columns: 62px 1fr 36px; gap: 10px; margin-top: 14px; align-items: stretch; }
.meter-labels {
  display: flex; flex-direction: column; justify-content: space-between;
  text-align: right; color: var(--muted); font-size: 11px; padding: 8px 0 6px;
}
.meter-frame {
  background: var(--card-deep); border-radius: 10px; padding: 6px; border: 1px solid #06100b;
  display: flex; flex-direction: column-reverse; gap: 4px;
}
.seg {
  height: 14px; border-radius: 3px; background: #2a3a33; transition: background .08s, box-shadow .08s;
}
.seg.on[data-zone="green"] { background: var(--green); box-shadow: 0 0 8px rgba(126,217,87,.45); }
.seg.on[data-zone="yellow"] { background: var(--lime); box-shadow: 0 0 8px rgba(242,210,51,.45); }
.seg.on[data-zone="orange"] { background: var(--amber); box-shadow: 0 0 8px rgba(240,128,47,.45); }
.seg.on[data-zone="red"] { background: var(--hot); box-shadow: 0 0 8px rgba(232,67,58,.5); }
.seg.on[data-zone="top"] { background: #fff2b0; box-shadow: 0 0 12px rgba(255,242,176,.7); }
.meter-marker {
  position: relative; color: var(--hot); font-size: 11px; font-weight: 700;
}
.meter-marker > * { position: absolute; left: 0; transform: translateY(-50%); transition: top .1s; }
.marker-arrow { font-size: 12px; }
.marker-val { left: 16px; font-size: 11px; }

/* ---------- verdict ---------- */
.verdict { text-align: center; margin: 16px 0 14px; min-height: 52px; }
.tier-name { font-family: Bungee, Inter, sans-serif; font-size: 20px; margin: 0; color: var(--cream); letter-spacing: .5px; }
.tier-line { color: var(--muted); margin: 6px 0 0; }

/* ---------- hold button ---------- */
.btn-hold {
  width: 100%; border: 0; border-radius: 999px; padding: 22px 16px;
  font-family: Bungee, Inter, sans-serif; font-size: 18px; color: #2b1d00; letter-spacing: .5px;
  background: linear-gradient(180deg, #ffd43b 0%, var(--yellow) 60%, #e2b312 100%);
  box-shadow: 0 6px 0 var(--yellow-deep), 0 14px 24px rgba(0,0,0,.4);
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  transition: transform .08s, box-shadow .08s, background .2s;
}
.btn-hold.holding { transform: translateY(5px); box-shadow: 0 1px 0 var(--yellow-deep), 0 6px 14px rgba(0,0,0,.4);
  background: linear-gradient(180deg, #ff8a5b 0%, #ff5c3a 70%, #d9402a 100%); color: #fff; }
.btn-hold.armed { animation: pulse 1.4s ease-in-out infinite; }
.btn-hold:disabled { opacity: .6; cursor: default; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.02); } }

/* ---------- pills ---------- */
.actions { margin-top: 14px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.actions-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; width: 100%; }
.btn-pill {
  border-radius: 999px; padding: 11px 16px; font-weight: 800; font-size: 13px; border: 1.5px solid var(--line);
  background: #14201a; color: var(--text); text-decoration: none; text-align: center; display: inline-block;
  transition: transform .08s, filter .15s;
}
.btn-pill:active { transform: translateY(1px); }
.btn-pill.red { background: var(--red); border-color: var(--red-deep); color: #fff; }
.btn-pill.yellow { background: var(--yellow); border-color: var(--yellow-deep); color: #2b1d00; }
.btn-pill.ghost { background: #14201a; }
.btn-pill.full { width: 100%; }
.btn-pill.big { padding: 15px; font-size: 15px; margin: 14px 0 6px; }
.btn-pill:disabled { opacity: .55; }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 4px; font-size: 12px; }
.check { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 6px; }
.check input { accent-color: var(--yellow); }

.status { text-align: center; color: var(--muted); min-height: 18px; margin: 10px 0 0; }
.record-line { text-align: center; color: var(--muted); font-size: 12px; margin: 10px 0 0; }

/* ---------- chip ---------- */
.chip-row { display: flex; justify-content: center; align-items: center; gap: 6px; margin-bottom: 12px; }
.chip { background: #14201a; border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px; font-size: 12px; color: var(--muted); }
.chip b { color: var(--cream); }
.chip-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--hot); margin-right: 4px; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .2; } }

/* ---------- board ---------- */
.top-head { display: flex; justify-content: space-between; color: var(--muted); font-size: 12px; margin: 0 2px 10px; }
.board { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.row {
  display: grid; grid-template-columns: 24px 36px 1fr auto; gap: 10px; align-items: center;
  background: var(--card); border: 1.5px solid var(--line); border-radius: 14px; padding: 10px 12px;
}
.row.mine-row { border-color: var(--gold); }
.rank { font-family: Bungee, Inter, sans-serif; color: var(--yellow); font-size: 14px; text-align: center; }
.play {
  width: 36px; height: 36px; border-radius: 50%; border: 1.5px solid var(--line); background: var(--card-deep);
  color: var(--text); display: grid; place-items: center; font-size: 12px; padding: 0;
}
.play.playing { border-color: var(--yellow); color: var(--yellow); }
.who { font-weight: 700; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who small { color: var(--muted); font-weight: 600; }
.wave { display: flex; align-items: flex-end; gap: 2px; height: 16px; margin-top: 4px; }
.wave i { flex: 1; min-width: 2px; background: #56695f; border-radius: 1px; display: block; }
.wave i.past { background: var(--yellow); }
.pts { font-family: Bungee, Inter, sans-serif; color: var(--yellow); font-size: 18px; }
.row-actions { grid-column: 1 / -1; display: flex; gap: 12px; justify-content: flex-end; }
.hint { color: var(--muted); text-align: center; margin: 8px 0; }
.foot { color: var(--muted); font-size: 11px; text-align: center; margin-top: 22px; }

/* ---------- mine ---------- */
.mine { margin-top: 22px; color: var(--muted); }
.mine summary { cursor: pointer; font-size: 12px; text-align: center; list-style: none; }
.mine summary::-webkit-details-marker { display: none; }
.mine .list { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 8px; }

/* ---------- torneo ---------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 12px; }
.field span { font-size: 12px; color: var(--muted); font-weight: 600; }
.field input, .field select {
  background: var(--card-deep); border: 1.5px solid var(--line); border-radius: 10px; color: var(--text);
  padding: 11px 12px; font-size: 16px; width: 100%; outline: none;
}
.field input:focus, .field select:focus { border-color: var(--gold); }
#t-code { text-transform: uppercase; letter-spacing: 3px; font-family: Bungee, Inter, sans-serif; }
.or { text-align: center; color: var(--muted); margin: 12px 0; font-size: 12px; }
.room-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.room-name { font-family: Bungee, Inter, sans-serif; color: var(--cream); font-size: 20px; margin: 0; }
.room-code { color: var(--muted); margin: 4px 0 0; font-size: 12px; }
.room-code b { color: var(--yellow); font-family: Bungee, Inter, sans-serif; letter-spacing: 2px; }
.share-row { display: flex; gap: 8px; margin-top: 12px; }
.share-row > * { flex: 1; padding-left: 8px; padding-right: 8px; }
.sub { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; margin: 18px 0 8px; }
.players { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.players li { background: #14201a; border: 1px solid var(--line); border-radius: 999px; padding: 5px 10px; font-size: 12px; }
.players li b { color: var(--yellow); }
.link-row { display: flex; justify-content: space-between; gap: 8px; align-items: center; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; }

/* ---------- modal / toast ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.65); display: grid; place-items: center; padding: 16px; z-index: 20; }
.modal-box { background: var(--card); border: 2px solid var(--orange); border-radius: var(--radius); padding: 18px; width: 100%; max-width: 340px; }
.modal-title { font-family: Bungee, Inter, sans-serif; color: var(--cream); font-size: 18px; margin: 0 0 14px; text-align: center; }
.toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #0b1310; color: var(--cream); border: 1px solid var(--gold); padding: 10px 16px; border-radius: 999px;
  font-size: 13px; z-index: 30; max-width: calc(100% - 32px); text-align: center;
}

/* ---------- jurado IA ---------- */
.jury { margin-top: 14px; background: var(--card); border: 2px solid var(--gold); border-radius: var(--radius); padding: 14px; }
.jury-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.jury-badge { font-weight: 800; color: var(--cream); font-size: 13px; }
.jury-status { color: var(--muted); font-size: 12px; }
.jury-status.thinking::after { content: ''; display: inline-block; width: 8px; height: 8px; margin-left: 6px; border-radius: 50%; background: var(--yellow); animation: blink 1s infinite; vertical-align: middle; }
.jury-style { font-family: Bungee, Inter, sans-serif; color: var(--yellow); font-size: 16px; margin: 10px 0 6px; }
.jury-comment { margin: 0; line-height: 1.5; color: var(--text); font-size: 14px; }
.jury-comment.susp { color: #ffb4ae; }
.jury-spec { display: block; width: 100%; border-radius: 10px; margin-top: 12px; border: 1px solid var(--line); }
.jury-breakdown { list-style: none; margin: 12px 0 0; padding: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; font-size: 12px; color: var(--muted); }
.jury-breakdown li { display: flex; justify-content: space-between; border-bottom: 1px dashed var(--line); padding-bottom: 3px; }
.jury-breakdown b { color: var(--cream); }
.verdict-line { grid-column: 1 / -1; font-size: 12px; color: var(--muted); line-height: 1.4; margin-top: 2px; }
.verdict-line b { color: var(--yellow); }
.verdict-line.susp { color: #ffb4ae; }
.row.susp-row { opacity: .75; }
.row.susp-row .pts { color: var(--muted); }
