:root {
  --bg-dark: #0e131f;
  --bg-panel: #161f33;
  --bg-card: #1f2b47;
  --border-color: #33466e;
  --accent-pink: #ff2e7e;
  --accent-cyan: #00f0ff;
  --accent-gold: #ffd12b;
  --accent-green: #00e676;
  --accent-red: #ff385c;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

body {
  background: radial-gradient(circle at 50% 0%, #1d2948 0%, #0b0f19 100%);
  color: var(--text-main);
  font-family: 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', -apple-system, BlinkMacSystemFont, sans-serif;
  min-height: 100vh;
  touch-action: manipulation;
}

button {
  touch-action: manipulation;
  font-family: inherit;
}

#app {
  max-width: 1360px;
  margin: 0 auto;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Header HUD */
.hud-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  background: rgba(22, 31, 51, 0.96);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 8px 14px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.4);
}

.brand-box {
  display: flex;
  align-items: center;
  gap: 8px;
}

.on-air-badge {
  background: #334155;
  color: #94a3b8;
  font-size: 10px;
  font-weight: 900;
  padding: 3px 8px;
  border-radius: 999px;
  letter-spacing: 0.8px;
  border: 1px solid #475569;
}

.on-air-badge.live {
  background: var(--accent-red);
  color: #fff;
  border-color: #ff8fa3;
  box-shadow: 0 0 14px var(--accent-red);
  animation: blinkAir 0.6s infinite alternate;
}

@keyframes blinkAir {
  from { opacity: 1; }
  to { opacity: 0.7; }
}

.brand-box h1 {
  font-size: 18px;
  font-weight: 900;
  color: #fff;
}

.brand-box .sub-jp {
  font-size: 12px;
  color: var(--accent-pink);
  margin-left: 4px;
}

.stats-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.stat-pill {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 4px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 90px;
}

.stat-pill .label {
  font-size: 9px;
  color: var(--text-muted);
  font-weight: 700;
}

.stat-pill .value {
  font-size: 15px;
  font-weight: 900;
}

.stat-pill .value.cyan { color: var(--accent-cyan); }
.stat-pill .value.gold { color: var(--accent-gold); }

.hearts {
  font-size: 14px;
  letter-spacing: 2px;
}

.header-actions {
  display: flex;
  gap: 6px;
}

/* Main Grid */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 330px;
  gap: 12px;
  align-items: start;
}

.booth-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Stadium Monitor */
.stadium-monitor {
  position: relative;
  background: #0a1420;
  border: 2px solid var(--border-color);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

#stadium-canvas {
  width: 100%;
  height: 210px;
  object-fit: cover;
  display: block;
}

/* PA Speech Bubble */
.pa-speech-bubble {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.97);
  color: #0f172a;
  border: 3px solid var(--accent-pink);
  border-radius: 12px;
  padding: 8px 14px;
  width: 90%;
  max-width: 680px;
  text-align: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.65);
  z-index: 10;
}

.pa-speaker-tag {
  font-size: 10px;
  font-weight: 900;
  color: var(--accent-pink);
  margin-bottom: 2px;
}

.pa-speech-text {
  font-size: 18px;
  font-weight: 900;
  line-height: 1.3;
  color: #0f172a;
}

/* Reaction Toast */
.reaction-toast {
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(15, 23, 42, 0.95);
  border: 2px solid var(--accent-gold);
  border-radius: 10px;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  width: 92%;
  max-width: 520px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.65);
  z-index: 12;
}

.reaction-avatar {
  font-size: 26px;
  flex-shrink: 0;
}

.reaction-who {
  font-size: 10px;
  font-weight: 800;
  color: var(--accent-gold);
}

.reaction-msg {
  font-size: 12.5px;
  font-weight: 800;
  color: #fff;
  line-height: 1.3;
}

/* Broadcast Desk */
.broadcast-desk {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 10px;
}

/* Handwritten Memo Slip */
.memo-card {
  background: #fffbeb;
  color: #1e293b;
  border: 2px solid #f59e0b;
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
}

.memo-top-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.memo-badge {
  font-size: 11px;
  font-weight: 900;
  color: #b45309;
}

.memo-difficulty {
  background: #dc2626;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
}

.timer-inline {
  font-size: 12px;
  font-weight: 900;
  color: #0f172a;
  background: #fde68a;
  padding: 2px 7px;
  border-radius: 6px;
}

.timer-bar-bg {
  width: 100%;
  height: 7px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
}

.timer-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #00e676, #f59e0b, #ef4444);
  transition: width 0.1s linear;
}

.memo-content {
  text-align: center;
}

.memo-kanji {
  font-size: 19px;
  font-weight: 900;
  color: #0f172a;
  background: #fef3c7;
  border: 2px solid #f59e0b;
  border-radius: 8px;
  padding: 10px 8px;
  line-height: 1.3;
}

.memo-hint {
  font-size: 11px;
  font-weight: 700;
  color: #78350f;
  margin-top: 5px;
}

/* Script Console */
.script-console {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.script-preview-bar {
  background: #0d1322;
  border: 1px solid #283759;
  border-radius: 8px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.preview-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.mic-lamp {
  font-size: 12px;
  font-weight: 800;
  color: var(--accent-cyan);
}

.btn-undo-inline {
  background: #28354e;
  color: #e2e8f0;
  border: 1px solid #475569;
  border-radius: 6px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.btn-undo-inline:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.assembled-preview {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
}

.slot-pill {
  background: #1a243d;
  border: 1.5px dashed #475569;
  border-radius: 6px;
  padding: 5px 4px;
  font-size: 11.5px;
  font-weight: 800;
  color: var(--text-muted);
  text-align: center;
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  text-overflow: ellipsis;
}

.slot-pill.active {
  border-style: solid;
  border-color: var(--accent-gold);
  color: var(--accent-gold);
  background: rgba(255, 209, 43, 0.1);
}

.slot-pill.filled {
  border-style: solid;
  border-color: var(--accent-cyan);
  background: rgba(0, 240, 255, 0.14);
  color: #fff;
}

.choices-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  min-height: 112px;
}

.choice-btn {
  background: var(--bg-card);
  color: #fff;
  border: 2px solid #3b4f7d;
  border-radius: 10px;
  padding: 12px 10px;
  font-size: 15px;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.1s ease;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  line-height: 1.25;
}

@media (hover: hover) {
  .choice-btn:hover {
    background: #2b3c63;
    border-color: var(--accent-cyan);
  }
}

.choice-btn:active {
  background: #334b7c;
  border-color: var(--accent-gold);
  transform: scale(0.97);
}

.console-footer {
  display: flex;
  justify-content: flex-end;
}

.btn-announce {
  width: 100%;
  background: linear-gradient(135deg, #ff2e7e, #ff6b00);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
}

.btn-announce:disabled {
  background: #2b3548;
  color: #64748b;
  cursor: not-allowed;
}

/* Sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.panel-card {
  background: rgba(22, 31, 51, 0.95);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  padding: 10px 12px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.panel-card h2 {
  font-size: 13px;
  font-weight: 900;
  color: var(--accent-gold);
}

.badge-sub {
  font-size: 10px;
  background: rgba(0, 240, 255, 0.15);
  color: var(--accent-cyan);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 800;
}

.bloopers-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 190px;
  overflow-y: auto;
}

.empty-blooper {
  font-size: 11px;
  color: #64748b;
  padding: 10px 8px;
  text-align: center;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
}

.blooper-item {
  background: #1b253d;
  border-left: 3px solid var(--accent-pink);
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}

.blooper-text {
  font-weight: 800;
  color: #fff;
  line-height: 1.3;
}

.btn-replay-voice {
  background: #2d3e66;
  color: var(--accent-cyan);
  border: none;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 800;
  cursor: pointer;
  white-space: nowrap;
}

.share-buttons-col {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.btn-x-share {
  flex: 1.3;
  background: #000;
  color: #fff;
  border: 1.5px solid #38bdf8;
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 12.5px;
  font-weight: 900;
  cursor: pointer;
}

.btn-snap {
  flex: 1;
  background: linear-gradient(135deg, #ff2e7e, #ff8800);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 9px 10px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.btn-util {
  background: #1e293b;
  color: #e2e8f0;
  border: 1px solid #334155;
  border-radius: 6px;
  padding: 5px 9px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.btn-util.full-w {
  width: 100%;
  padding: 8px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 12, 22, 0.88);
  backdrop-filter: blur(5px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 12px;
}

.modal-box {
  background: linear-gradient(180deg, #1e2946 0%, #12182b 100%);
  border: 2px solid var(--accent-gold);
  border-radius: 16px;
  padding: 20px;
  max-width: 480px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
}

.modal-badge {
  display: inline-block;
  background: var(--accent-pink);
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 6px;
}

.modal-box h2 {
  font-size: 22px;
  font-weight: 900;
  margin-bottom: 6px;
}

.modal-box p {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.modal-stats-box {
  background: rgba(0, 0, 0, 0.35);
  border-radius: 10px;
  padding: 10px;
  margin-bottom: 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 13.5px;
}

.modal-best-blooper {
  background: rgba(255, 46, 126, 0.15);
  border: 1px solid var(--accent-pink);
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 14px;
  font-size: 12.5px;
  font-weight: 800;
  line-height: 1.4;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.btn-primary {
  background: linear-gradient(135deg, #00f0ff, #0088ff);
  color: #06101e;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  width: 100%;
}

.btn-secondary-sm {
  background: #28354e;
  color: #e2e8f0;
  border: 1px solid #475569;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.free-input {
  width: 100%;
  background: #0f172a;
  color: #fff;
  border: 2px solid var(--accent-cyan);
  border-radius: 8px;
  padding: 10px;
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
}

.hidden {
  display: none !important;
}

/* ==========================================
   MOBILE OPTIMIZATION (Fits 100% on 1 screen)
   ========================================== */
@media (max-width: 960px) {
  .main-grid {
    grid-template-columns: 1fr;
  }
  .broadcast-desk {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  #app {
    padding: 6px 8px;
    gap: 6px;
  }

  .hide-mobile {
    display: none !important;
  }

  .hud-header {
    padding: 6px 10px;
    gap: 6px;
  }

  .brand-box h1 {
    font-size: 15px;
  }

  .brand-box .sub-jp {
    display: none;
  }

  .stats-row {
    gap: 4px;
    width: 100%;
    justify-content: space-between;
  }

  .stat-pill {
    flex: 1;
    min-width: 0;
    padding: 3px 6px;
  }

  .stat-pill .value {
    font-size: 13px;
  }

  #stadium-canvas {
    height: 120px;
  }

  .pa-speech-bubble {
    top: 6px;
    padding: 5px 10px;
  }

  .pa-speech-text {
    font-size: 14px;
  }

  .reaction-toast {
    bottom: 4px;
    padding: 4px 8px;
  }

  .reaction-avatar {
    font-size: 20px;
  }

  .reaction-msg {
    font-size: 11px;
  }

  .booth-column {
    gap: 6px;
  }

  .broadcast-desk {
    gap: 6px;
  }

  .memo-card {
    padding: 8px 10px;
    gap: 5px;
  }

  .memo-kanji {
    font-size: 16px;
    padding: 7px 6px;
  }

  .memo-hint {
    font-size: 10.5px;
    margin-top: 3px;
  }

  .script-console {
    padding: 8px 10px;
    gap: 6px;
  }

  .assembled-preview {
    grid-template-columns: repeat(2, 1fr);
    gap: 4px;
  }

  .slot-pill {
    min-height: 26px;
    font-size: 11px;
    padding: 3px 4px;
  }

  .choices-grid {
    gap: 6px;
    min-height: 106px;
  }

  .choice-btn {
    min-height: 50px;
    padding: 8px 6px;
    font-size: 14px;
  }
}
