/* Cronômetro Jiu-Jitsu — identidade Team Gutty (preto/vermelho) × Checkmat (preto/branco) */
:root {
  --black: #070707;
  --bg: #0a0a0a;
  --panel: #131313;
  --panel-2: #1c1c1c;
  --line: #2a2a2a;
  --white: #f4f2ef;
  --muted: #8d8a86;
  --red: #e3171e;
  --red-deep: #8c070c;
  --red-ink: #ffffff;
  --radius: 14px;
  --display: "Archivo", "Arial Black", system-ui, sans-serif;
  --body: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --grain: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--white); }
body {
  font-family: var(--body); font-size: 16px; line-height: 1.4;
  min-height: 100dvh; overflow-x: hidden;
}
body::after {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 100;
  background-image: var(--grain); opacity: .07; mix-blend-mode: overlay;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
svg { width: 1.4em; height: 1.4em; display: block; }
img { display: block; }
[hidden] { display: none !important; }

.display, h1, h2, h3, .f-label, .step-n, .kicker, .btn, .chip, .card-name, .card-idx {
  font-family: var(--display);
}

.screen {
  max-width: 640px; margin: 0 auto; position: relative;
  padding: max(18px, env(safe-area-inset-top)) 18px max(28px, env(safe-area-inset-bottom));
}

/* ---------- topo ---------- */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; position: relative; z-index: 1; }
.top h2 { font-size: 1rem; margin: 0; text-transform: uppercase; font-stretch: 125%; font-weight: 800; letter-spacing: .02em; text-align: center; }
.teams { display: flex; align-items: center; gap: 10px; }
.teams img { width: 44px; height: 44px; object-fit: contain; }
.teams img + .x + img { width: 40px; height: 40px; }
.teams .x { color: var(--muted); font-weight: 700; }
.spacer { width: 44px; }

.icon-btn {
  width: 44px; height: 44px; border-radius: 12px; flex: none;
  display: grid; place-items: center;
  background: var(--panel-2); color: var(--white); border: 1px solid var(--line);
}
.icon-btn.sm { width: 40px; height: 40px; }
.icon-btn.sm svg { width: 1.05em; height: 1.05em; }
.icon-btn:active { transform: scale(.95); }

/* ---------- home ---------- */
.h-bg {
  position: absolute; inset: 0 0 auto 0; height: 420px; z-index: 0; pointer-events: none;
  background: repeating-conic-gradient(#2a0305 0 25%, #050505 0 50%) 0 0 / 88px 88px;
  -webkit-mask-image: linear-gradient(#000 0%, rgba(0, 0, 0, .55) 40%, transparent 100%);
  mask-image: linear-gradient(#000 0%, rgba(0, 0, 0, .55) 40%, transparent 100%);
  opacity: .9;
}
.h-vert {
  position: absolute; z-index: 1; right: 14px; top: 104px;
  writing-mode: vertical-rl; transform: rotate(180deg);
  font-family: var(--display); font-stretch: 125%; font-weight: 900; text-transform: uppercase;
  font-size: .6rem; letter-spacing: .22em; color: var(--red);
}
.hero { position: relative; z-index: 1; padding: 34px 28px 26px 0; }
.kicker {
  margin: 0 0 10px; color: var(--red); text-transform: uppercase; font-weight: 800;
  letter-spacing: .22em; font-size: .72rem; font-stretch: 125%;
}
.hero h1 {
  margin: 0; font-stretch: 125%; font-weight: 900; text-transform: uppercase;
  font-size: clamp(1.8rem, 8.6vw, 3.6rem); line-height: .92; letter-spacing: -0.035em;
}
.hero h1 em { font-style: normal; color: var(--red); }

.quick {
  position: relative; z-index: 1;
  background: linear-gradient(180deg, #141414, #0e0e0e);
  border: 1px solid var(--line); border-top: 3px solid var(--red);
  border-radius: 4px 4px var(--radius) var(--radius); padding: 20px 16px 16px; margin-bottom: 30px;
}
.q-step { margin-bottom: 20px; }
.step-n {
  display: block; color: var(--red); font-size: .66rem; font-weight: 800; letter-spacing: .2em;
  text-transform: uppercase; font-stretch: 125%;
}
.q-step h2, .sec-head h2 {
  margin: 4px 0 12px; font-size: 1.15rem; font-weight: 900; font-stretch: 125%; text-transform: uppercase; letter-spacing: -.01em;
}
.link { display: block; width: 100%; text-align: center; margin-top: 12px; color: var(--muted); font-size: .88rem; padding: 6px; }
.link u { color: var(--white); text-underline-offset: 3px; }

.mine { position: relative; z-index: 1; }
.sec-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sec-head h2 { margin: 0; }
.list { display: grid; gap: 10px; }
.card {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px;
}
.card-main { flex: 1; display: flex; align-items: center; gap: 14px; text-align: left; padding: 8px; border-radius: 10px; min-width: 0; }
.card-main:active { background: var(--panel-2); }
.card-idx { font-weight: 900; font-stretch: 125%; color: transparent; -webkit-text-stroke: 1px var(--red); font-size: 1.6rem; line-height: 1; }
.card-txt { flex: 1; display: grid; min-width: 0; gap: 2px; }
.card-name { font-weight: 900; font-stretch: 125%; text-transform: uppercase; font-size: 1rem; letter-spacing: -.01em; }
.card-sum { color: var(--muted); font-size: .88rem; font-variant-numeric: tabular-nums; }
.card-play {
  width: 46px; height: 46px; border-radius: 10px; flex: none;
  display: grid; place-items: center; background: var(--red); color: #fff;
}
.card-play svg { width: 1.1em; height: 1.1em; margin-left: 2px; }
.empty { color: var(--muted); text-align: center; }
.foot {
  margin-top: 40px; text-align: center; font-family: var(--display); font-stretch: 125%; font-weight: 900;
  text-transform: uppercase; font-size: 3.4rem; line-height: 1; letter-spacing: -.03em;
  color: transparent; -webkit-text-stroke: 1px #3a3a3a;
}

.resume {
  position: relative; z-index: 1;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  background: #1b0506; border: 1px solid var(--red-deep); border-radius: var(--radius);
  padding: 14px; margin-bottom: 16px;
}
.resume b { display: block; font-family: var(--display); font-stretch: 125%; text-transform: uppercase; font-size: .9rem; }
.resume span { color: #d6b4b5; font-size: .9rem; }
.resume-btns { display: flex; gap: 8px; }

/* ---------- botões ---------- */
.btn {
  min-height: 48px; padding: 0 20px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--line);
  font-weight: 800; font-stretch: 112%; text-transform: uppercase; letter-spacing: .04em; font-size: .85rem;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
}
.btn.primary { background: var(--red); border-color: var(--red); color: var(--red-ink); }
.btn.primary:active { background: #c10f15; }
.btn.big { min-height: 60px; font-size: 1rem; font-stretch: 125%; border-radius: 12px; }
.btn.big svg { width: 1.1em; height: 1.1em; }
.btn.ghost { background: transparent; min-height: 40px; padding: 0 14px; }
.btn.danger { background: transparent; color: var(--red); border-color: var(--red-deep); }
.btn.wide { width: 100%; }
.btn:active { transform: scale(.98); }
.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.actions .btn.danger { margin-right: auto; }

/* ---------- campos ---------- */
.field { display: grid; gap: 10px; margin-bottom: 24px; }
.f-label { font-weight: 800; color: var(--white); font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; font-stretch: 125%; }
.field input:not([type=range]) {
  height: 50px; padding: 0 14px; border-radius: 10px;
  background: var(--panel); border: 1px solid var(--line); font-size: 1.05rem;
}
.field input:focus { outline: 2px solid var(--red); outline-offset: 1px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 46px; padding: 0 16px; border-radius: 10px;
  background: var(--panel-2); border: 1.5px solid var(--line);
  font-weight: 800; font-size: .88rem; font-variant-numeric: tabular-nums;
}
.chip.on { background: rgba(227, 23, 30, .14); border-color: var(--red); color: #ff4d52; }
.chips.small .chip { min-height: 32px; padding: 0 11px; font-size: .78rem; }
.stepper {
  display: inline-flex; align-items: center; width: fit-content;
  background: var(--panel-2); border: 1.5px solid var(--line); border-radius: 10px;
}
.stepper output { min-width: 84px; text-align: center; font-size: 1.4rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.step { width: 52px; height: 48px; font-size: 1.6rem; font-weight: 500; }
.step:active { background: var(--panel); }
.total {
  border-left: 3px solid var(--red); padding: 10px 14px; color: var(--muted); margin: 4px 0 18px;
  font-variant-numeric: tabular-nums; font-size: .92rem; background: rgba(255, 255, 255, .02);
}
.total b { color: var(--white); }
#editor h3 { font-size: 1.05rem; margin: 8px 0 12px; text-transform: uppercase; font-stretch: 125%; font-weight: 900; }
#editor .total { margin-bottom: 30px; }

.alarms { display: grid; gap: 10px; }
.alarm {
  display: grid; grid-template-columns: auto 1fr; gap: 10px 14px; align-items: start;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px;
}
.alarm-txt { display: grid; gap: 4px; }
.alarm-txt b { font-family: var(--display); font-stretch: 112%; text-transform: uppercase; font-size: .88rem; letter-spacing: .02em; }
.alarm-txt small { color: var(--muted); }
.alarm-txt .chips { margin-top: 6px; }
.alarm-sound { grid-column: 2; display: flex; gap: 8px; align-items: center; }
.alarm-sound select {
  flex: 1; min-width: 0; height: 40px; padding: 0 10px; border-radius: 10px;
  background: var(--panel-2); border: 1px solid var(--line);
}
.alarm.off .alarm-txt, .alarm.off .alarm-sound { opacity: .4; }

.switch {
  width: 50px; height: 30px; border-radius: 999px; flex: none; position: relative;
  background: #3a3a3a; transition: background .15s; margin-top: 1px;
}
.switch i { position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch.on { background: var(--red); }
.switch.on i { transform: translateX(20px); }

/* ---------- modal ---------- */
#modal { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .7); display: grid; place-items: end center; }
.sheet {
  width: min(560px, 100%); background: var(--panel); border: 1px solid var(--line); border-top: 3px solid var(--red);
  border-radius: 18px 18px 0 0; padding: 22px 20px max(22px, env(safe-area-inset-bottom));
}
.sheet h3 { margin: 0 0 18px; text-transform: uppercase; font-stretch: 125%; font-weight: 900; }
@media (min-width: 700px) { #modal { place-items: center; } .sheet { border-radius: 18px; } }
.m-msg { font-size: 1.15rem; margin: 0; }
.set-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.note { color: var(--muted); font-size: .88rem; }
input[type=range] { flex: 1; accent-color: var(--red); height: 30px; }

/* ---------- timer ---------- */
#timer {
  --fg: var(--white);
  --track: rgba(255, 255, 255, .14);
  --arc: var(--red);
  --chip: rgba(255, 255, 255, .1);
  max-width: none; min-height: 100dvh; margin: 0;
  display: grid; grid-template-rows: auto 1fr auto; grid-template-columns: minmax(0, 1fr); gap: 8px;
  padding: max(14px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom));
  background: var(--black); color: var(--fg);
  transition: background-color .35s, color .35s;
  position: relative; overflow: hidden;
  --ring: min(84vw, 50vh);
}
.t-bg { position: absolute; inset: 0; pointer-events: none; opacity: 0; transition: opacity .35s; }
#timer > *:not(.t-bg) { position: relative; z-index: 1; }
#timer > .lockov, #timer > .done { position: absolute; }

/* rola: vermelho Gutty */
#timer[data-phase=round] { background: radial-gradient(120% 80% at 50% 45%, #d3141b 0%, #9b0910 55%, #5c0408 100%); --track: rgba(0, 0, 0, .28); --arc: #fff; --chip: rgba(0, 0, 0, .22); }
/* descanso: branco Checkmat */
#timer[data-phase=rest] { background: #ecebe8; --fg: #0a0a0a; --track: rgba(0, 0, 0, .1); --arc: #0a0a0a; --chip: rgba(0, 0, 0, .08); }
#timer[data-phase=rest] .t-bg { opacity: .06; background: repeating-conic-gradient(#000 0 25%, transparent 0 50%) 0 0 / 120px 120px; }
/* preparação: tabuleiro preto e vermelho */
#timer[data-phase=prep] .t-bg { opacity: .55; background: repeating-conic-gradient(#3a0406 0 25%, #050505 0 50%) 0 0 / 110px 110px; }

#timer.warn[data-phase=round] { animation: flash-red 1s steps(1) infinite; }
#timer.warn[data-phase=rest], #timer.warn[data-phase=prep] { animation: flash-rest 1s steps(1) infinite; }
@keyframes flash-red { 50% { background: #050505; } }
@keyframes flash-rest { 50% { background: var(--red); color: #fff; --arc: #fff; } }
#timer.paused { background: #1b1b1b !important; --fg: var(--white); --arc: #6d6d6d; --track: rgba(255, 255, 255, .08); --chip: rgba(255, 255, 255, .08); animation: none !important; }
#timer.paused .t-bg { opacity: 0; }

.t-top { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.t-logo { width: 40px; height: 40px; object-fit: contain; }
.t-logo.sq { width: 34px; height: 34px; }
#t-name { font-family: var(--display); font-stretch: 125%; font-weight: 800; text-transform: uppercase; font-size: .78rem; letter-spacing: .12em; opacity: .8; text-align: center; }

.t-center { display: grid; justify-items: center; align-content: center; text-align: center; min-height: 0; gap: 6px; }
.t-pill {
  display: inline-flex; align-items: center; gap: 10px; padding: 8px 18px; border-radius: 999px; background: var(--chip);
  font-family: var(--display); font-stretch: 125%; font-weight: 900; letter-spacing: .14em; text-transform: uppercase;
  font-size: clamp(.95rem, 3.6vmin, 2rem);
}
.t-pill i { width: .55em; height: .55em; border-radius: 50%; background: currentColor; animation: blink 1.2s ease-in-out infinite; }
#timer.paused .t-pill i { animation: none; opacity: .4; }
@keyframes blink { 50% { opacity: .25; } }
.t-round { font-family: var(--display); font-stretch: 125%; font-weight: 700; font-size: clamp(.8rem, 2.6vmin, 1.4rem); letter-spacing: .18em; opacity: .75; font-variant-numeric: tabular-nums; }

.ring { position: relative; width: var(--ring); height: var(--ring); display: grid; place-items: center; margin: 8px 0; }
.ring svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: var(--track); stroke-width: 9; }
.ring-arc { fill: none; stroke: var(--arc); stroke-width: 9; stroke-linecap: round; stroke-dasharray: 1000 1000; transition: stroke-dasharray .12s linear, stroke .35s; }
.t-time {
  font-family: var(--display); font-weight: 900; font-stretch: 100%;
  font-variant-numeric: tabular-nums; letter-spacing: -0.04em; line-height: 1;
  font-size: calc(var(--ring) * .25);
}
.t-next { font-weight: 600; font-size: clamp(.9rem, 2.8vmin, 1.5rem); opacity: .8; font-variant-numeric: tabular-nums; }

.t-controls { display: grid; justify-items: center; gap: 14px; }
.pill-btn {
  min-width: min(260px, 70vw); height: 62px; padding: 0 34px; border-radius: 999px;
  background: var(--fg); color: var(--black);
  font-family: var(--display); font-stretch: 125%; font-weight: 900; text-transform: uppercase; letter-spacing: .1em; font-size: 1.05rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25);
}
#timer[data-phase=rest]:not(.paused) .pill-btn { background: #0a0a0a; color: #fff; }
#timer.paused .pill-btn { background: var(--red); color: #fff; }
.pill-btn:active { transform: scale(.97); }
.t-sec { display: flex; justify-content: center; gap: clamp(8px, 3vw, 22px); }
.ctl {
  width: clamp(60px, 17vw, 84px); height: clamp(60px, 17vw, 84px); border-radius: 16px; flex: none;
  display: grid; place-items: center; align-content: center; gap: 4px; background: var(--chip);
}
.ctl svg { width: 1.3em; height: 1.3em; }
.ctl b { font-family: var(--display); font-weight: 900; font-size: 1.05rem; }
.ctl small { font-size: .66rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; opacity: .85; }
.ctl:active { transform: scale(.94); }
.lock-btn {
  display: flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 999px;
  background: transparent; font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; opacity: .7;
}
.lock-btn svg { width: 1.05em; height: 1.05em; }

.lockov { inset: 0; z-index: 20; display: grid; align-items: end; justify-items: center; padding-bottom: max(24px, env(safe-area-inset-bottom)); }
.unlock {
  position: relative; overflow: hidden; display: flex; align-items: center; gap: 10px;
  padding: 16px 24px; border-radius: 999px; background: rgba(0, 0, 0, .75); color: #fff; font-weight: 800;
  text-transform: uppercase; letter-spacing: .06em; font-size: .85rem;
  user-select: none; -webkit-user-select: none; touch-action: none;
}
.unlock i { position: absolute; left: 0; bottom: 0; height: 4px; width: 0; background: var(--red); }
.unlock.holding i { width: 100%; transition: width 1.2s linear; }

.done {
  inset: 0; z-index: 30; display: grid; place-items: center; padding: 20px; color: var(--white);
  background: rgba(5, 5, 5, .94);
}
.done::before {
  content: ""; position: absolute; inset: 0; opacity: .35;
  background: repeating-conic-gradient(#3a0406 0 25%, transparent 0 50%) 0 0 / 110px 110px;
  -webkit-mask-image: radial-gradient(circle at 50% 50%, transparent 30%, #000 80%);
  mask-image: radial-gradient(circle at 50% 50%, transparent 30%, #000 80%);
}
.done-box { text-align: center; position: relative; }
.done-logos { display: flex; justify-content: center; align-items: center; gap: 18px; margin-bottom: 18px; }
.done-logos img { width: 72px; height: 72px; object-fit: contain; }
.done-logos img + img { width: 64px; height: 64px; }
.done-kicker { display: block; color: var(--red); font-family: var(--display); font-stretch: 125%; font-weight: 900; text-transform: uppercase; font-size: clamp(3rem, 14vmin, 7rem); line-height: .9; letter-spacing: -.03em; }
.done h2 { font-size: clamp(1.1rem, 4vmin, 2rem); margin: 10px 0 4px; text-transform: uppercase; font-stretch: 125%; font-weight: 900; }
.done p { color: var(--muted); font-size: 1.05rem; margin: 0; }
.done .actions { justify-content: center; }

/* paisagem: tablet na parede / TV */
@media (orientation: landscape) {
  #timer { grid-template-columns: minmax(0, 1fr) auto; grid-template-rows: auto 1fr; column-gap: 28px; --ring: min(60vh, 50vw); }
  .t-top { grid-column: 1 / -1; }
  .t-center { grid-column: 1; }
  .t-controls { grid-column: 2; grid-row: 2; align-content: center; }
  .t-sec { display: grid; grid-template-columns: repeat(2, auto); }
  .pill-btn { min-width: 0; width: 100%; }
}
@media (orientation: landscape) and (max-height: 520px) {
  #timer { --ring: min(58vh, 46vw); }
  .t-top { display: none; }
  #timer { grid-template-rows: 1fr; }
  .t-center, .t-controls { grid-row: 1; }
  .ctl { width: 54px; height: 54px; }
  .ctl small { display: none; }
  .pill-btn { height: 52px; }
}

@media (prefers-reduced-motion: reduce) {
  #timer.warn { animation: none !important; }
  .t-pill i { animation: none; }
}
