@import url("https://fonts.googleapis.com/css2?family=Dela+Gothic+One&family=Zen+Maru+Gothic:wght@500;700;900&display=swap");

/* クイズ番組のスタジオをイメージした配色: 濃紺の舞台 + 照明の黄色 + 早押しボタンの赤 */
:root {
  --bg: #12153a;
  --bg-2: #1b2058;
  --panel: #232a6e;
  --panel-2: #2c3483;
  --line: #3b44a0;
  --text: #f4f3ff;
  --muted: #a9addb;
  --gold: #ffd23f;
  --gold-deep: #e0a800;
  --red: #ff3b4e;
  --red-deep: #c4142a;
  --green: #31d39a;
  --blue: #4cc3ff;
  --radius: 16px;
  --font: "Zen Maru Gothic", "Hiragino Maru Gothic ProN", "Meiryo", sans-serif;
  --display: "Dela Gothic One", "Zen Maru Gothic", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font);
  font-weight: 500;
  color: var(--text);
  background:
    radial-gradient(ellipse at 50% -10%, rgba(255, 210, 63, 0.18), transparent 55%),
    radial-gradient(ellipse at 10% 110%, rgba(76, 195, 255, 0.12), transparent 50%),
    var(--bg);
  background-attachment: fixed;
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
}

a {
  color: var(--gold);
}

.hidden {
  display: none !important;
}

/* ---------- 共通部品 ---------- */

.screen {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 24px 16px 48px;
}

.panel {
  width: 100%;
  max-width: 760px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
}

.card h2 {
  margin: 0 0 12px;
  font-size: 1.15rem;
}

.logo {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(2.2rem, 8vw, 3.6rem);
  letter-spacing: 0.04em;
  margin: 8px 0 4px;
  text-align: center;
  color: var(--gold);
  text-shadow: 0 4px 0 var(--red-deep), 0 8px 24px rgba(255, 59, 78, 0.35);
}

.logo small {
  display: block;
  font-family: var(--font);
  font-size: 0.9rem;
  color: var(--muted);
  text-shadow: none;
  letter-spacing: 0.2em;
  margin-top: 6px;
}

.hint {
  color: var(--muted);
  font-size: 0.9rem;
  margin: 4px 0;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}

.top-bar a.home {
  font-family: var(--display);
  color: var(--gold);
  text-decoration: none;
  font-size: 1.2rem;
}

label {
  display: block;
  font-weight: 700;
  font-size: 0.9rem;
  margin: 12px 0 6px;
}

input[type="text"],
input[type="number"],
textarea,
select {
  width: 100%;
  font: inherit;
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  outline: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(255, 210, 63, 0.25);
}

textarea {
  resize: vertical;
  min-height: 64px;
}

button {
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  border: none;
  border-radius: 999px;
  padding: 10px 18px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  transition: transform 0.08s, filter 0.15s;
}

button:hover {
  filter: brightness(1.15);
}

button:active {
  transform: translateY(1px);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: none;
}

button.primary {
  background: linear-gradient(180deg, var(--gold), var(--gold-deep));
  color: #2a1b00;
  border-color: transparent;
  box-shadow: 0 4px 0 #9a7400;
}

button.danger {
  background: transparent;
  color: var(--red);
  border-color: var(--red);
}

button.small {
  padding: 6px 12px;
  font-size: 0.85rem;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.row > .grow {
  flex: 1;
  min-width: 0;
}

.error-text {
  color: var(--red);
  font-weight: 700;
  margin: 8px 0 0;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--panel-2);
  border: 1px solid var(--gold);
  padding: 10px 18px;
  border-radius: 999px;
  z-index: 50;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  max-width: calc(100% - 32px);
}

.badge {
  display: inline-block;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  color: var(--muted);
}

.badge.gold {
  color: #2a1b00;
  background: var(--gold);
  border-color: var(--gold);
}

/* ---------- トップページ ---------- */

.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin: 28px 0;
}

.menu-card {
  display: block;
  text-decoration: none;
  color: var(--text);
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 20px;
  padding: 24px;
  transition: transform 0.15s, border-color 0.15s;
}

.menu-card:hover {
  transform: translateY(-3px);
  border-color: var(--gold);
}

.menu-card .icon {
  font-size: 2.4rem;
}

.menu-card h2 {
  font-family: var(--display);
  font-weight: 400;
  margin: 8px 0;
  color: var(--gold);
}

.menu-card p {
  margin: 0;
  color: var(--muted);
}

/* ---------- 問題セット一覧 ---------- */

.set-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.set-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--bg-2);
  border: 1px solid var(--line);
}

.set-item.selectable {
  cursor: pointer;
}

.set-item.selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(255, 210, 63, 0.35);
}

.set-item .meta {
  flex: 1;
  min-width: 0;
}

.set-item .title {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.set-item .sub {
  color: var(--muted);
  font-size: 0.8rem;
}

.empty {
  color: var(--muted);
  text-align: center;
  padding: 16px;
}

/* ---------- 問題エディタ ---------- */

.question-editor {
  display: grid;
  gap: 12px;
}

.q-row {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
}

.q-row-head {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.q-row-head .no {
  font-family: var(--display);
  color: var(--gold);
  flex: 1;
}

.q-row-head button {
  padding: 4px 10px;
  font-size: 0.8rem;
}

.q-row textarea {
  min-height: 56px;
}

.q-row .q-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

@media (max-width: 560px) {
  .q-row .q-fields {
    grid-template-columns: 1fr;
  }
}

.sticky-actions {
  position: sticky;
  bottom: 12px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding: 12px;
  background: rgba(18, 21, 58, 0.92);
  border: 1px solid var(--line);
  border-radius: 999px;
  backdrop-filter: blur(6px);
  margin-top: 16px;
}

.key-box {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.8rem;
  word-break: break-all;
  background: var(--bg);
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px dashed var(--line);
}

/* ---------- 対戦: ロビー ---------- */

.room-code {
  font-family: var(--display);
  font-size: clamp(2rem, 9vw, 3rem);
  letter-spacing: 0.2em;
  color: var(--gold);
  text-align: center;
}

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

.share-row input {
  flex: 1;
  min-width: 0;
  font-size: 0.85rem;
}

.player-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  font-weight: 700;
}

.chip.me {
  border-color: var(--gold);
}

.chip.off {
  opacity: 0.45;
}

.rules-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 4px 16px;
}

.rules-grid label {
  font-size: 0.82rem;
  color: var(--muted);
}

.rules-grid .unit {
  display: flex;
  align-items: center;
  gap: 6px;
}

.rules-grid .unit span {
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.85rem;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  margin-top: 14px;
}

.check input {
  width: 20px;
  height: 20px;
  accent-color: var(--gold);
}

.rules-summary {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 6px 16px;
}

.rules-summary li {
  font-size: 0.9rem;
}

.rules-summary b {
  color: var(--gold);
}

/* ---------- 対戦: ゲーム画面 ---------- */

.game-layout {
  width: 100%;
  max-width: 980px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  gap: 16px;
  align-items: start;
}

/* 列幅(260px)を超えて広がらないようにする */
.game-layout > * {
  min-width: 0;
}

@media (max-width: 820px) {
  .game-layout {
    grid-template-columns: 1fr;
  }
  .scoreboard {
    order: 2;
  }
}

.q-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.q-number {
  font-family: var(--display);
  font-size: 1.6rem;
  color: var(--gold);
}

.bonus-tag {
  font-weight: 900;
  color: #2a1b00;
  background: linear-gradient(90deg, var(--gold), #ff9f1c);
  padding: 2px 10px;
  border-radius: 6px;
  animation: pulse 1s infinite alternate;
}

@keyframes pulse {
  from {
    transform: scale(1);
  }
  to {
    transform: scale(1.08);
  }
}

.question-board {
  min-height: 170px;
  background: linear-gradient(180deg, #0c0f2c, #161a4a);
  border: 3px solid var(--gold-deep);
  border-radius: 18px;
  padding: 22px;
  font-size: clamp(1.15rem, 3.6vw, 1.6rem);
  font-weight: 700;
  line-height: 1.7;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.5), 0 0 30px rgba(255, 210, 63, 0.12);
  word-break: break-word;
}

.question-board .cursor {
  display: inline-block;
  width: 0.55em;
  height: 1.1em;
  vertical-align: -0.15em;
  background: var(--gold);
  margin-left: 2px;
  animation: blink 0.8s steps(1) infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

.status-line {
  min-height: 2.4em;
  margin: 12px 0;
  text-align: center;
  font-weight: 700;
  font-size: 1.1rem;
}

.timer-bar {
  height: 10px;
  border-radius: 999px;
  background: var(--bg-2);
  overflow: hidden;
  margin: 8px 0;
}

.timer-bar > div {
  height: 100%;
  background: linear-gradient(90deg, var(--red), var(--gold));
  width: 100%;
}

/* 早押しボタン */
.buzz-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
}

.buzzer {
  width: min(56vw, 210px);
  height: min(56vw, 210px);
  border-radius: 50%;
  border: 8px solid #f1f1f6;
  background: radial-gradient(circle at 35% 30%, #ff8a95, var(--red) 45%, var(--red-deep));
  box-shadow: 0 12px 0 #7d0a18, 0 18px 40px rgba(255, 59, 78, 0.45);
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.6rem, 7vw, 2.3rem);
  color: #fff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
  padding: 0;
  touch-action: manipulation;
  user-select: none;
}

.buzzer:active:not(:disabled) {
  transform: translateY(8px);
  box-shadow: 0 4px 0 #7d0a18, 0 8px 20px rgba(255, 59, 78, 0.45);
}

.buzzer:disabled {
  background: radial-gradient(circle at 35% 30%, #8a8fb8, #4a4f7a 60%, #34385e);
  box-shadow: 0 12px 0 #20233f;
  opacity: 1;
}

.buzzer.lit,
.buzzer.lit:disabled {
  background: radial-gradient(circle at 35% 30%, #ff8a95, var(--red) 45%, var(--red-deep));
  box-shadow: 0 12px 0 #7d0a18;
  animation: lamp 0.25s infinite alternate;
}

@keyframes lamp {
  from {
    box-shadow: 0 12px 0 #7d0a18, 0 0 20px 6px rgba(255, 210, 63, 0.6);
  }
  to {
    box-shadow: 0 12px 0 #7d0a18, 0 0 50px 18px rgba(255, 210, 63, 0.9);
  }
}

.answer-form {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.answer-form input {
  flex: 1;
  font-size: 1.2rem;
  font-weight: 700;
  border: 2px solid var(--gold);
}

.reveal-box {
  text-align: center;
  padding: 16px;
  border-radius: 16px;
  background: var(--panel);
  border: 2px solid var(--line);
  margin: 12px 0;
}

.reveal-box .answer {
  font-family: var(--display);
  font-size: clamp(1.6rem, 6vw, 2.4rem);
  color: var(--gold);
}

.reveal-box .alt {
  color: var(--muted);
  font-size: 0.85rem;
}

.reveal-box .note {
  margin-top: 8px;
  font-size: 0.95rem;
}

.feed {
  list-style: none;
  padding: 0;
  margin: 0;
  max-height: 220px;
  overflow-y: auto;
  font-size: 0.9rem;
}

.feed li {
  padding: 6px 0;
  border-bottom: 1px dashed var(--line);
}

.feed .ok {
  color: var(--green);
  font-weight: 900;
}

.feed .ng {
  color: var(--red);
  font-weight: 900;
}

.scoreboard ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
  /* 既定の min-width:auto だと中身の最小幅まで広がり、行が枠からはみ出す */
  min-width: 0;
}

.scoreboard li {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  transition: border-color 0.2s, background 0.2s;
}

.scoreboard li.me {
  border-color: var(--gold);
}

.scoreboard li.buzzing {
  background: var(--red-deep);
  border-color: var(--gold);
}

.scoreboard li.locked,
.scoreboard li.resting,
.scoreboard li.off {
  opacity: 0.5;
}

.scoreboard .rank {
  width: 1.6em;
  text-align: center;
  font-family: var(--display);
  color: var(--muted);
}

.scoreboard .name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}

.scoreboard .pts {
  font-family: var(--display);
  color: var(--gold);
  flex: 0 0 auto;
}

.scoreboard .tag {
  font-size: 0.7rem;
  color: var(--muted);
  flex: 0 0 auto;
  white-space: nowrap;
}

.host-controls {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 12px;
}

.countdown {
  font-family: var(--display);
  font-size: 5rem;
  color: var(--gold);
  text-align: center;
  animation: pop 1s infinite;
}

@keyframes pop {
  0% {
    transform: scale(1.4);
    opacity: 0;
  }
  30% {
    transform: scale(1);
    opacity: 1;
  }
}

/* 最終結果 */
.podium {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 8px;
}

.podium li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 14px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  font-weight: 700;
}

.podium li:nth-child(1) {
  background: linear-gradient(90deg, rgba(255, 210, 63, 0.35), var(--bg-2));
  border-color: var(--gold);
  font-size: 1.2rem;
}

.podium .place {
  font-family: var(--display);
  width: 2.2em;
  color: var(--gold);
}

.podium .name {
  flex: 1;
}

.podium .detail {
  color: var(--muted);
  font-size: 0.8rem;
}

/* ---------- サウンド切替・フッター・モーダル ---------- */

.sound-controls {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 40;
}

.mute-btn {
  width: 44px;
  height: 44px;
  padding: 0;
  font-size: 1.2rem;
}

.sound-panel {
  /* 将来BGMを追加したときに音量パネルを出す場所(現在は効果音のON/OFFのみ) */
  position: absolute;
  right: 0;
  top: 52px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
}

.legal-footer {
  text-align: center;
  font-size: 0.8rem;
  color: var(--muted);
  margin-top: 24px;
}

.legal-footer a {
  color: var(--muted);
}

.copyright {
  margin: 6px 0 0;
}

.legal-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.legal-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}

.legal-modal-box {
  position: relative;
  width: 100%;
  max-width: 760px;
  height: min(88vh, 900px);
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
}

.legal-modal-frame {
  width: 100%;
  height: 100%;
  border: none;
}

.legal-modal-close {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 36px;
  height: 36px;
  padding: 0;
  background: #fff;
  color: #333;
  border: 1px solid #ccc;
}

.disconnect-banner {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.disconnect-box {
  background: var(--panel);
  border: 1px solid var(--gold);
  border-radius: 16px;
  padding: 24px;
  text-align: center;
  max-width: 360px;
}

.disconnect-title {
  font-weight: 900;
  font-size: 1.1rem;
  margin: 0 0 8px;
}

/* 問題の画像(国旗など)。縦に伸びすぎないよう高さで抑える。 */
.question-image {
  margin: 0 0 12px;
  text-align: center;
}

.question-image img {
  max-width: 100%;
  max-height: 220px;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
}

@media (max-width: 600px) {
  .question-image img {
    max-height: 150px;
  }
}
