:root {
  --text: #ffffff; --muted: #cbd5e1; --green: #22c55e; --yellow: #facc15;
  --red: #ef4444; --blue: #38bdf8; --border: rgba(255,255,255,.16);
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; }
body {
  font-family: Arial, Helvetica, sans-serif;
  background: radial-gradient(circle at top, #1e293b 0%, #020617 55%, #000 100%);
  color: var(--text);
}
a { color: var(--blue); }

.login-body { min-height: 100vh; overflow: auto; }
.login-page { width: 100%; min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card {
  width: min(460px, 100%); border: 1px solid var(--border); border-radius: 28px; padding: 34px;
  background: linear-gradient(180deg, rgba(15,23,42,.94), rgba(2,6,23,.96));
  box-shadow: 0 25px 80px rgba(0,0,0,.48);
}
.login-badge {
  display: inline-block; padding: 8px 14px; border-radius: 999px;
  background: rgba(56,189,248,.14); border: 1px solid rgba(56,189,248,.45);
  color: var(--blue); font-weight: 900; letter-spacing: 1px; margin-bottom: 16px;
}
.login-card h1 { margin: 0 0 8px; font-size: 34px; line-height: 1.05; }
.login-card p { margin: 0 0 22px; color: var(--muted); line-height: 1.4; }
.login-form { display: grid; gap: 16px; }
.login-form label { display: grid; gap: 8px; color: var(--muted); font-weight: 800; }
.login-form input { width: 100%; }
.login-button { width: 100%; margin-top: 8px; background: var(--green); padding: 16px; }
.login-error {
  margin-bottom: 16px; padding: 12px 14px; border-radius: 14px;
  background: rgba(239,68,68,.16); border: 1px solid rgba(239,68,68,.55);
  color: #fecaca; font-weight: 800;
}

.view-body { overflow: hidden; }
.view-page {
  width: 100vw; height: 100dvh; padding: clamp(8px, 1.4vw, 24px);
  display: grid; grid-template-rows: auto 1fr; gap: clamp(8px, 1.2vw, 18px); overflow: hidden;
}
.header {
  min-height: 0; display: grid; grid-template-columns: 1fr auto; gap: clamp(10px, 1.5vw, 22px);
  align-items: stretch; border: 2px solid var(--border); border-radius: clamp(14px, 2vw, 24px);
  padding: clamp(10px, 1.3vw, 20px) clamp(14px, 2vw, 28px);
  background: rgba(15,23,42,.78); box-shadow: 0 20px 60px rgba(0,0,0,.35); overflow: hidden;
}
.header-main { min-width: 0; display: flex; flex-direction: column; justify-content: center; }
.header-label {
  color: var(--muted); font-size: clamp(11px, 1.1vw, 20px);
  font-weight: 900; letter-spacing: 2px; text-transform: uppercase;
}
.header h1 {
  margin: 0; font-size: clamp(28px, 5.2vw, 82px); line-height: .95; letter-spacing: 1px;
  text-transform: uppercase; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.next-inline {
  margin-top: clamp(6px, .9vw, 12px); display: flex; align-items: baseline;
  gap: clamp(8px, 1vw, 18px); min-width: 0; font-weight: 900; text-transform: uppercase;
}
.next-inline span {
  color: var(--muted); font-size: clamp(12px, 1.3vw, 24px); letter-spacing: 1.2px; flex: none;
}
.next-inline strong {
  min-width: 0; color: var(--blue); font-size: clamp(20px, 3.2vw, 54px);
  line-height: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.stage-status {
  align-self: center; justify-self: end; padding: clamp(10px, 1vw, 16px) clamp(16px, 1.6vw, 28px);
  border-radius: 999px; font-size: clamp(18px, 2.4vw, 42px); font-weight: 1000;
  letter-spacing: 1px; text-transform: uppercase; white-space: nowrap; box-shadow: 0 15px 40px rgba(0,0,0,.35);
}
.status-playing { background: rgba(34,197,94,.18); border: 2px solid var(--green); color: var(--green); }
.status-stage { background: rgba(239,68,68,.18); border: 2px solid var(--red); color: var(--red); }
.hidden { opacity: 0; visibility: hidden; }
.grid {
  min-height: 0; display: grid; grid-template-columns: 1fr 1fr;
  grid-template-rows: minmax(0, 1fr) minmax(0, .44fr);
  grid-template-areas: "show show" "changeover free";
  gap: clamp(8px, 1.2vw, 18px);
}
.show-card { grid-area: show; } .changeover-card { grid-area: changeover; } .free-stage-card { grid-area: free; }
.card {
  min-width: 0; min-height: 0; border: 2px solid var(--border); border-radius: clamp(16px, 2.2vw, 30px);
  background: linear-gradient(180deg, rgba(15,23,42,.94), rgba(2,6,23,.94));
  box-shadow: 0 25px 80px rgba(0,0,0,.45); padding: clamp(12px, 2vw, 32px);
  display: flex; flex-direction: column; justify-content: center; overflow: hidden;
}
.label {
  color: var(--muted); text-transform: uppercase; font-weight: 900; letter-spacing: 1.4px;
  font-size: clamp(13px, 1.8vw, 34px); margin-bottom: clamp(8px, 1.3vw, 20px); line-height: 1.08;
}
.timer { font-variant-numeric: tabular-nums; font-weight: 900; letter-spacing: .02em; line-height: .9; white-space: nowrap; }
.timer.show { font-size: clamp(86px, 20vw, 285px); color: var(--yellow); text-shadow: 0 0 24px rgba(250,204,21,.25); }
.timer.normal { font-size: clamp(52px, 11vw, 160px); }
.warning { color: var(--red) !important; animation: blink 1s infinite; text-shadow: 0 0 32px rgba(239,68,68,.65); }
.finished-show {
  color: var(--red) !important; font-size: clamp(58px, 12vw, 180px) !important;
  letter-spacing: .04em; animation: blink 1s infinite; text-shadow: 0 0 36px rgba(239,68,68,.7);
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: .30; } }

.control-body { overflow: auto; }
.control-page { min-height: 100vh; padding: 24px; max-width: 1200px; margin: 0 auto; }
.control-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; }
.control-title h1 { margin: 0; font-size: 34px; }
.control-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.control-card { border: 1px solid var(--border); border-radius: 22px; background: rgba(15,23,42,.88); padding: 22px; }
.control-card.full { grid-column: 1 / -1; }
.control-card h2 { margin: 0 0 16px; font-size: 22px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
input {
  border: 1px solid var(--border); border-radius: 12px; padding: 14px;
  background: #020617; color: white; font-size: 18px; min-width: 90px;
}
input[type="text"] { flex: 1; min-width: 260px; text-transform: uppercase; }
button {
  border: 0; border-radius: 12px; padding: 14px 18px; font-size: 17px;
  font-weight: 900; cursor: pointer; color: #020617; background: #e2e8f0;
}
button.start { background: var(--green); }
button.pause { background: var(--yellow); }
button.reset { background: var(--red); color: white; }
button.blue { background: var(--blue); }
.preview {
  margin-top: 14px; padding: 14px; border-radius: 12px;
  background: #020617; color: var(--muted); font-size: 18px; line-height: 1.5;
}
.preview strong { color: white; }

@media (max-width: 900px) {
  .view-body { overflow: auto; }
  .view-page { height: auto; min-height: 100dvh; }
  .header { grid-template-columns: 1fr; }
  .stage-status { justify-self: start; }
  .grid {
    grid-template-columns: 1fr 1fr; grid-template-rows: auto;
    grid-template-areas: "show show" "changeover free";
  }
  .timer.show { font-size: clamp(70px, 22vw, 180px); }
  .timer.normal { font-size: clamp(36px, 13vw, 90px); }
  .finished-show { font-size: clamp(42px, 13vw, 120px) !important; }
  .next-inline { align-items: flex-start; flex-direction: column; }
  .control-grid { grid-template-columns: 1fr; }
  .control-title { align-items: flex-start; flex-direction: column; }
}