:root {
  --bg-0: #0a0612;
  --bg-1: #150a26;
  --gold: #f3d27a;
  --gold-2: #c9a24b;
  --pink: #ff5da8;
  --purple: #a173ff;
  --cyan: #67e8f9;
  --danger: #ff5a6a;

  --text: #f6f0ff;
  --muted: rgba(246, 240, 255, 0.62);

  --glass: rgba(255, 255, 255, 0.055);
  --glass-strong: rgba(255, 255, 255, 0.1);
  --stroke: rgba(255, 255, 255, 0.14);
  --stroke-strong: rgba(255, 255, 255, 0.28);

  --radius: 20px;
  --serif: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", serif;
  --sans: ui-sans-serif, system-ui, -apple-system, "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  font-family: var(--sans);
  color: var(--text);
  background: var(--bg-0);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ---------- 背景（画像素材なしのネオン夜景） ---------- */
.bg-neon {
  position: fixed;
  inset: 0;
  z-index: -3;
  background:
    radial-gradient(60% 45% at 15% 10%, rgba(161, 115, 255, 0.30), transparent 60%),
    radial-gradient(55% 40% at 85% 5%, rgba(255, 93, 168, 0.28), transparent 60%),
    radial-gradient(70% 55% at 50% 110%, rgba(243, 210, 122, 0.16), transparent 60%),
    linear-gradient(160deg, var(--bg-1), var(--bg-0) 70%);
}

.bg-skyline {
  position: fixed;
  inset: auto 0 0 0;
  height: 42vh;
  z-index: -2;
  background:
    repeating-linear-gradient(90deg,
      transparent 0 5px,
      rgba(255, 255, 255, 0.045) 5px 6px,
      transparent 6px 22px);
  mask-image: linear-gradient(to top, rgba(0, 0, 0, 0.9), transparent 92%);
  -webkit-mask-image: linear-gradient(to top, rgba(0, 0, 0, 0.9), transparent 92%);
  opacity: 0.7;
}

.app-shell {
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 22px 18px calc(40px + env(safe-area-inset-bottom));
}

/* ---------- 共通カード（グラスモーフィズム） ---------- */
.glass-card {
  position: relative;
  border: 1px solid var(--stroke);
  border-radius: var(--radius);
  background: var(--glass);
  backdrop-filter: blur(16px) saturate(140%);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  box-shadow:
    0 18px 50px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.screen { display: none; }
.screen.active { display: block; animation: fadeUp 0.35s ease; }
.hidden { display: none !important; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-card, .panel, .draw-card-area, .rule-card-area { padding: 20px; }

h1, h2, h3, p { margin-top: 0; }

h2 {
  font-family: var(--serif);
  font-size: clamp(22px, 5vw, 32px);
  letter-spacing: 0.01em;
  margin-bottom: 12px;
}

h3 { font-size: 18px; }

.kicker {
  font-weight: 800;
  letter-spacing: 0.32em;
  font-size: 11px;
  color: var(--gold);
  margin: 0 0 10px;
}

.muted { color: var(--muted); font-weight: 600; line-height: 1.6; }

/* ---------- タイトル画面 ---------- */
.title-wrap {
  min-height: 78vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 18px;
  padding: 24px 6px;
}

.neon-title {
  font-family: var(--serif);
  font-weight: 800;
  font-size: clamp(52px, 16vw, 116px);
  line-height: 0.92;
  margin: 0;
  letter-spacing: 0.02em;
  color: #fff;
  background: linear-gradient(180deg, #fff6df 0%, var(--gold) 55%, var(--gold-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 18px rgba(243, 210, 122, 0.35));
}

.neon-title span {
  background: linear-gradient(180deg, #ffd7ec 0%, var(--pink) 60%, var(--purple) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 22px rgba(255, 93, 168, 0.45));
}

.tagline {
  font-family: var(--serif);
  font-size: clamp(16px, 4.4vw, 22px);
  color: var(--text);
  border: 1px solid var(--stroke-strong);
  border-radius: 999px;
  padding: 12px 22px;
  background: rgba(255, 93, 168, 0.12);
  box-shadow: 0 0 24px rgba(255, 93, 168, 0.25), inset 0 1px 0 rgba(255,255,255,0.1);
  line-height: 1.5;
}

.title-menu {
  width: min(420px, 100%);
  display: grid;
  gap: 12px;
  margin-top: 6px;
}

/* ---------- ボタン ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--stroke-strong);
  border-radius: 14px;
  background: var(--glass-strong);
  color: var(--text);
  padding: 13px 18px;
  font-family: var(--sans);
  font-weight: 800;
  font-size: 16px;
  letter-spacing: 0.02em;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: transform 0.12s ease, box-shadow 0.2s ease, filter 0.2s ease;
}

.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(2px) scale(0.99); }

.btn.primary {
  border: none;
  color: #241408;
  background: linear-gradient(135deg, #fff2cf, var(--gold) 45%, var(--gold-2));
  box-shadow: 0 8px 26px rgba(243, 210, 122, 0.4);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.35);
}

.btn.secondary {
  border: none;
  color: #fff;
  background: linear-gradient(135deg, var(--pink), var(--purple));
  box-shadow: 0 8px 26px rgba(161, 115, 255, 0.4);
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--stroke);
}

.btn.danger {
  color: #fff;
  border: 1px solid rgba(255, 90, 106, 0.6);
  background: rgba(255, 90, 106, 0.14);
}

.btn.huge { width: 100%; font-size: 19px; padding: 17px 18px; border-radius: 16px; }
.btn.small { font-size: 13px; padding: 9px 12px; border-radius: 11px; }
.btn.full { width: 100%; margin-top: 12px; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; filter: none; }

.button-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ---------- 注意書き ---------- */
.notice {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.6;
  color: var(--text);
  background: rgba(255, 90, 106, 0.12);
  border: 1px solid rgba(255, 90, 106, 0.35);
  border-radius: 12px;
  padding: 12px 14px;
  white-space: pre-line;
}
.notice.soft {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--stroke);
  color: var(--muted);
  max-width: 440px;
}

/* ---------- 入力 ---------- */
input, textarea {
  width: 100%;
  border: 1px solid var(--stroke-strong);
  border-radius: 12px;
  padding: 14px;
  font-size: 16px;
  font-weight: 700;
  font-family: var(--sans);
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
}
input::placeholder, textarea::placeholder { color: rgba(246, 240, 255, 0.4); }
input:focus, textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(243, 210, 122, 0.2);
}
textarea { min-height: 92px; resize: vertical; }

/* ---------- セットアップ ---------- */
.setup-toolbar {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  margin: 18px 0 14px;
}

.count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--stroke-strong);
  border-radius: 999px;
  background: rgba(243, 210, 122, 0.14);
  color: var(--gold);
  padding: 11px 16px;
  font-size: 16px;
  font-weight: 800;
}
.count-badge span { color: var(--text); font-size: 20px; margin-right: 4px; }

.player-form { display: grid; gap: 10px; margin-bottom: 14px; }

.player-form-row {
  display: grid;
  grid-template-columns: 42px 1fr auto auto auto;
  gap: 8px;
  align-items: center;
  border: 1px solid var(--stroke);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  padding: 10px;
}

.seat-number {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--pink), var(--purple));
  color: #fff;
  font-weight: 800;
}

.setup-hint {
  color: var(--muted);
  font-size: 13px;
  border: 1px dashed var(--stroke);
  border-radius: 12px;
  padding: 10px 12px;
  margin-bottom: 16px;
}

/* ---------- 設定画面 ---------- */
.field-label { color: var(--gold); margin-bottom: 6px; }

.unit-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.unit-option {
  border: 1px solid var(--stroke);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  padding: 15px 10px;
  font-weight: 800;
  font-size: 16px;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}
.unit-option.active {
  border-color: transparent;
  background: linear-gradient(135deg, #fff2cf, var(--gold) 45%, var(--gold-2));
  color: #241408;
  box-shadow: 0 6px 20px rgba(243, 210, 122, 0.35);
}

.custom-row { margin-bottom: 14px; }

.drink-preview {
  display: flex;
  align-items: baseline;
  gap: 10px;
  flex-wrap: wrap;
  border: 1px solid var(--stroke);
  border-radius: 14px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.03);
  margin-bottom: 16px;
}
.drink-preview span { color: var(--muted); font-size: 12px; font-weight: 700; }
.drink-preview strong { font-size: 22px; color: var(--gold); }
.drink-preview em { color: var(--muted); font-style: normal; font-size: 14px; }

/* ---------- ステータスバー ---------- */
.status-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 12px;
  margin-bottom: 16px;
}
.status-strip div {
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 10px;
  text-align: center;
  background: rgba(0, 0, 0, 0.2);
}
.status-strip span { display: block; font-size: 10px; letter-spacing: 0.1em; color: var(--muted); font-weight: 700; margin-bottom: 4px; }
.status-strip strong { font-size: 16px; }
.status-strip .s-queen.on { border-color: var(--pink); box-shadow: 0 0 16px rgba(255, 93, 168, 0.4); }
.status-strip .s-queen.on strong { color: var(--pink); }
.status-strip .s-double.on { border-color: var(--gold); box-shadow: 0 0 16px rgba(243, 210, 122, 0.35); }
.status-strip .s-double.on strong { color: var(--gold); }

/* ---------- ゲーム本体 ---------- */
.game-grid {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}

.draw-card-area { text-align: center; }
.rule-card-area { min-height: 400px; }
.turn-label { color: var(--muted); font-size: 13px; font-weight: 700; margin-bottom: 2px; }

.neon-name, .neon-title { line-height: 1.1; }
.neon-name {
  font-family: var(--serif);
  color: var(--gold);
  text-shadow: 0 0 20px rgba(243, 210, 122, 0.4);
}

/* カード（フリップ演出） */
.playing-card {
  width: min(240px, 66vw);
  aspect-ratio: 2.5 / 3.5;
  margin: 18px auto;
  perspective: 1400px;
}
.card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 0.65s cubic-bezier(0.2, 0.85, 0.3, 1.1);
}
.playing-card.flipped .card-inner { transform: rotateY(180deg); }
.playing-card.dealing { animation: dealIn 0.4s ease; }

@keyframes dealIn {
  from { opacity: 0; transform: translateY(-28px) rotate(-8deg) scale(0.9); }
  to { opacity: 1; transform: translateY(0) rotate(0) scale(1); }
}

.card-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 18px;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.card-back {
  background:
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.15), transparent 40%),
    repeating-linear-gradient(45deg, rgba(161,115,255,0.5) 0 12px, rgba(255,93,168,0.5) 12px 24px),
    var(--bg-1);
  border: 2px solid var(--gold);
  box-shadow: inset 0 0 0 6px rgba(0, 0, 0, 0.25), 0 0 30px rgba(161, 115, 255, 0.4);
}
.back-mark {
  font-family: var(--serif);
  font-size: 64px;
  color: var(--gold);
  text-shadow: 0 0 18px rgba(243, 210, 122, 0.7);
}

.card-front {
  transform: rotateY(180deg);
  background: linear-gradient(160deg, #ffffff, #f4eefb);
  border: 2px solid var(--gold);
  box-shadow: 0 0 34px rgba(243, 210, 122, 0.45);
  color: #1a1020;
}
.card-rank { font-family: var(--serif); font-size: clamp(64px, 18vw, 110px); line-height: 1; font-weight: 800; }
.card-suit { position: absolute; right: 16px; bottom: 30px; font-size: 40px; }
.card-corner { position: absolute; font-weight: 800; font-size: 20px; white-space: pre; line-height: 1; text-align: center; }
.card-corner.top { top: 12px; left: 14px; }
.card-corner.bottom { bottom: 12px; right: 14px; transform: rotate(180deg); }
.card-front.red { color: #d81f5a; }
.card-front.black { color: #1a1020; }

.rule-text {
  font-size: 18px;
  font-weight: 700;
  line-height: 1.7;
  white-space: pre-line;
  color: var(--text);
}

.action-area { display: grid; gap: 10px; margin-top: 16px; }

/* アクション内のメッセージ */
.msg {
  border-radius: 12px;
  padding: 12px 14px;
  font-weight: 700;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-line;
  border: 1px solid var(--stroke);
  background: rgba(255, 255, 255, 0.04);
}
.msg.drink { border-color: rgba(255, 93, 168, 0.5); background: rgba(255, 93, 168, 0.1); }
.msg.queen { border-color: var(--pink); background: rgba(255, 93, 168, 0.16); }
.msg.info { border-color: var(--stroke); }
.msg.gold { border-color: var(--gold); background: rgba(243, 210, 122, 0.12); }

/* ---------- パネル ---------- */
.panel { margin-bottom: 16px; }
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.panel-head h2 { margin-bottom: 0; }

.panel-note {
  border: 1px solid var(--stroke);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  padding: 6px 12px;
  font-weight: 700;
  font-size: 12px;
}

.player-state-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.player-chip {
  border: 1px solid var(--stroke);
  border-radius: 16px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.03);
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
}
.player-chip h3 { margin-bottom: 10px; font-size: 20px; font-family: var(--serif); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.player-chip .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 10px; }
.player-chip .stats span { font-size: 13px; color: var(--muted); font-weight: 700; }
.player-chip .stats span b { color: var(--text); }
.player-chip .badge { font-size: 11px; padding: 2px 8px; border-radius: 999px; font-weight: 800; }
.player-chip .badge.turn { background: var(--gold); color: #241408; }
.player-chip .badge.q { background: var(--pink); color: #fff; }
.player-chip .badge.d { background: var(--purple); color: #fff; }
.player-chip.active { border-color: var(--gold); box-shadow: 0 0 22px rgba(243, 210, 122, 0.3); }
.player-chip.queen { border-color: var(--pink); box-shadow: 0 0 22px rgba(255, 93, 168, 0.3); }

/* ---------- リスト ---------- */
.rule-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.rule-list li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--stroke);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.03);
  font-weight: 700;
  line-height: 1.5;
}
.rule-list li small { color: var(--muted); font-weight: 600; }

.rules-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.rule-tile {
  border: 1px solid var(--stroke);
  border-radius: 16px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.03);
}
.rule-tile h3 { margin-bottom: 8px; color: var(--gold); font-family: var(--serif); }
.rule-tile p { color: var(--muted); font-weight: 600; line-height: 1.6; font-size: 14px; margin: 0; }

.rule-create-box { display: grid; gap: 10px; }

.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--stroke);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  padding: 8px 14px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}
.chip:hover { background: rgba(255, 255, 255, 0.12); }
.chip:active { transform: translateY(1px); }

/* ---------- 結果画面 ---------- */
.result-content { display: grid; gap: 12px; margin: 18px 0; }
.result-hero {
  text-align: center;
  border: 1px solid var(--gold);
  border-radius: 18px;
  padding: 22px;
  background: radial-gradient(circle at 50% 0%, rgba(243, 210, 122, 0.22), transparent 70%);
  box-shadow: 0 0 40px rgba(243, 210, 122, 0.3);
}
.result-hero .crown { font-size: 40px; }
.result-hero .label { color: var(--gold); letter-spacing: 0.2em; font-size: 12px; font-weight: 800; }
.result-hero .name { font-family: var(--serif); font-size: clamp(30px, 8vw, 48px); color: var(--text); margin: 6px 0; }
.result-hero .score { color: var(--muted); font-weight: 700; }

.title-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.title-card {
  border: 1px solid var(--stroke);
  border-radius: 16px;
  padding: 16px;
  background: rgba(255, 255, 255, 0.03);
}
.title-card .t-name { color: var(--pink); font-weight: 800; font-size: 15px; margin-bottom: 4px; }
.title-card .t-holder { font-family: var(--serif); font-size: 20px; }
.title-card .t-detail { color: var(--muted); font-size: 13px; font-weight: 600; margin-top: 2px; }

.result-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.stat-box { border: 1px solid var(--stroke); border-radius: 14px; padding: 12px; background: rgba(0,0,0,0.2); }
.stat-box span { display: block; font-size: 12px; color: var(--muted); font-weight: 700; }
.stat-box strong { font-size: 16px; }

/* ---------- モーダル ---------- */
.modal {
  width: min(560px, calc(100vw - 28px));
  max-height: 86vh;
  overflow: auto;
  padding: 20px;
  border: 1px solid var(--stroke-strong);
  color: var(--text);
}
.modal::backdrop { background: rgba(5, 2, 12, 0.7); backdrop-filter: blur(4px); }
.selection-grid { display: grid; gap: 10px; }
.selection-grid .btn.picked { background: linear-gradient(135deg, var(--pink), var(--purple)); color: #fff; border-color: transparent; }

/* ---------- レスポンシブ ---------- */
@media (max-width: 760px) {
  .app-shell { padding: 16px 12px calc(30px + env(safe-area-inset-bottom)); }
  .button-grid, .game-grid, .status-strip { grid-template-columns: 1fr; }
  .status-strip { grid-template-columns: repeat(2, 1fr); }
  .rule-card-area { min-height: auto; }
  .setup-toolbar { grid-template-columns: 1fr; }
  .setup-toolbar .btn { width: 100%; }
  .player-form-row { grid-template-columns: 38px 1fr 40px 40px; }
  .player-form-row .remove-slot { grid-column: 2 / -1; width: 100%; }
  .panel-head { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  .card-inner { transition: none; }
  .playing-card.dealing { animation: none; }
  .screen.active { animation: none; }
}
