/* ============================
   ごるバトGO！ - Light Green Design
   ============================ */

:root {
  /* Base colors - Light Green Theme */
  --bg-primary: #f0f7f0;
  --bg-secondary: #e4f0e4;
  --bg-card: rgba(255, 255, 255, 0.85);
  --bg-glass: rgba(255, 255, 255, 0.6);
  --bg-glass-hover: rgba(255, 255, 255, 0.85);

  /* Text */
  --text-primary: #1a3a1a;
  --text-secondary: #3d6b3d;
  --text-muted: #7a9e7a;

  /* Accent / Positive (UI green) */
  --positive: #16a34a;
  --positive-light: #bbf7d0;
  --positive-glow: rgba(22, 163, 74, 0.15);
  --positive-gradient: linear-gradient(135deg, #16a34a, #22c55e, #4ade80);

  /* Card positive = blue */
  --card-positive: #2563eb;
  --card-positive-light: #dbeafe;
  --card-positive-glow: rgba(37, 99, 235, 0.15);

  /* Negative */
  --negative: #dc2626;
  --negative-light: #fecaca;
  --negative-glow: rgba(220, 38, 38, 0.12);
  --negative-gradient: linear-gradient(135deg, #b91c1c, #ef4444, #f87171);

  /* Player colors */
  --player1: #3b82f6;
  --player2: #ec4899;
  --player3: #f59e0b;
  --player4: #8b5cf6;

  /* UI */
  --border-subtle: rgba(22, 163, 74, 0.1);
  --border-light: rgba(22, 163, 74, 0.2);
  --border-medium: rgba(22, 163, 74, 0.3);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 28px;
  --shadow-soft: 0 2px 16px rgba(22, 90, 40, 0.06);
  --shadow-card: 0 4px 24px rgba(22, 90, 40, 0.08);
  --shadow-elevated: 0 8px 40px rgba(22, 90, 40, 0.1);
  --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);

  /* Spacing */
  --header-height: 60px;
}

/* ============================
   Reset & Base
   ============================ */

*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'M PLUS Rounded 1c', 'Outfit', sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* ゴルフコース風背景レイヤー */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  /* 空（上）→ 地平線 → フェアウェイ（下）のグラデーション */
  background:
    linear-gradient(
      180deg,
      #b8d9f0 0%,        /* 空・水色 */
      #cce8f5 18%,       /* 薄い空 */
      #d4edda 35%,       /* 地平線付近・薄緑 */
      #6aad5e 50%,       /* 遠くの芝 */
      #4d9640 65%,       /* 中距離のフェアウェイ */
      #3a7d32 80%,       /* 手前の芝 */
      #2d6426 100%       /* グリーン深色 */
    );
  pointer-events: none;
  z-index: 0;
}

/* ぼかし＆霞効果レイヤー */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background:
    /* 雲っぽいふんわり白 */
    radial-gradient(ellipse 80% 25% at 50% 12%, rgba(255,255,255,0.55) 0%, transparent 100%),
    /* 地平線付近の光 */
    radial-gradient(ellipse 100% 20% at 50% 38%, rgba(220, 240, 210, 0.4) 0%, transparent 100%),
    /* 全体を白くフロスト */
    linear-gradient(180deg,
      rgba(255,255,255,0.45) 0%,
      rgba(255,255,255,0.25) 40%,
      rgba(255,255,255,0.35) 100%
    );
  backdrop-filter: blur(2px);
  pointer-events: none;
  z-index: 0;
}

/* ============================
   Screens
   ============================ */

.screen {
  display: none;
  position: relative;
  z-index: 1;
  min-height: 100vh;
}

.screen.active {
  display: block;
  animation: fadeIn 0.5s ease;
}

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

/* ============================
   START SCREEN
   ============================ */

.start-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 60px;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

.logo-area {
  text-align: center;
  margin-bottom: 28px;
  width: 100%;
}

.logo-image-wrap {
  width: 100%;
  margin: 0 auto 16px;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-elevated);
  position: relative;
}

.logo-image-wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  border: 2px solid rgba(255, 255, 255, 0.4);
  pointer-events: none;
}

.logo-hero-img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
}

.logo-badge {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: linear-gradient(135deg, #16a34a, #22c55e);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  box-shadow: 0 4px 20px rgba(22, 163, 74, 0.25);
  animation: float 3s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

.logo-emoji {
  font-size: 42px;
}

.logo-title {
  font-family: 'Outfit', 'Noto Sans JP', sans-serif;
  font-size: 3.2rem;
  font-weight: 900;
  background: linear-gradient(135deg, #16a34a, #059669, #047857);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: 0.05em;
  line-height: 1.1;
}

.logo-subtitle {
  font-family: 'Outfit', sans-serif;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.3em;
  color: var(--text-muted);
  margin-top: 4px;
  text-transform: uppercase;
}

.logo-desc {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-top: 8px;
  line-height: 1.7;
  font-weight: 500;
}

/* Setup Card */
.setup-card {
  width: 100%;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: var(--radius-lg);
  padding: 24px 18px;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 8px 32px rgba(40, 90, 40, 0.12), 0 1px 0 rgba(255,255,255,0.8) inset;
  overflow: hidden;
}

.setup-section {
  margin-bottom: 24px;
}

.setup-section:last-of-type {
  margin-bottom: 28px;
}

.setup-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}

/* Count selector */
.player-count-selector,
.hole-count-selector {
  display: flex;
  gap: 8px;
}

.count-btn {
  flex: 1;
  padding: 12px;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.5);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  line-height: 1.4;
}

.round-mode-selector .count-btn {
  min-height: 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.mode-btn-2set {
  gap: 2px;
}

.mode-sub {
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0;
}

.count-btn.active .mode-sub {
  color: var(--positive);
  opacity: 0.85;
}

.count-btn:hover {
  background: rgba(255, 255, 255, 0.8);
  border-color: var(--positive);
}

.count-btn.active {
  background: linear-gradient(135deg, rgba(22, 163, 74, 0.1), rgba(34, 197, 94, 0.08));
  border-color: var(--positive);
  color: var(--positive);
  font-weight: 700;
  box-shadow: 0 0 16px var(--positive-glow);
}

/* Name inputs */
.player-name-inputs {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.name-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
  min-width: 0;
}

.name-input-row.hidden {
  display: none;
}

.name-input {
  flex: 1;
  min-width: 0;
  padding: 12px 16px;
  border: 2.5px solid var(--player-border, var(--border-light));
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.7);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  transition: var(--transition);
  width: 100%;
  box-shadow: 0 2px 8px color-mix(in srgb, var(--player-border, transparent) 15%, transparent);
}

.name-input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

.name-input:focus {
  outline: none;
  background: #fff;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--player-border, var(--positive)) 20%, transparent);
}

/* Buttons */
.btn-primary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 16px 24px;
  border: none;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, #16a34a, #22c55e);
  color: white;
  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 16px rgba(22, 163, 74, 0.25);
  position: relative;
  overflow: hidden;
}

.btn-primary::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent, rgba(255,255,255,0.2), transparent);
  transform: translateX(-100%);
  transition: transform 0.6s;
}

.btn-primary:hover::before {
  transform: translateX(100%);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(22, 163, 74, 0.3);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  padding: 12px 20px;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.5);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.85);
  border-color: var(--positive);
}

.btn-secondary:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.btn-ghost {
  padding: 12px 20px;
  border: none;
  background: none;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.btn-ghost:hover {
  color: var(--text-secondary);
}

.btn-danger {
  width: 100%;
  padding: 14px 24px;
  border: 1.5px solid var(--negative);
  border-radius: var(--radius-md);
  background: rgba(220, 38, 38, 0.06);
  color: var(--negative);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  margin-bottom: 12px;
}

.btn-danger:hover {
  background: rgba(220, 38, 38, 0.12);
}

.btn-icon {
  font-size: 1.3rem;
}

.btn-icon-small {
  width: 40px;
  height: 40px;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.6);
  color: var(--text-primary);
  font-size: 1.2rem;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-icon-small:hover {
  background: rgba(255, 255, 255, 0.9);
  border-color: var(--positive);
}

.rules-toggle {
  margin-top: 20px;
}

.rules-toggle .btn-ghost {
  background: rgba(255, 255, 255, 0.65);
  border: 1.5px solid rgba(255, 255, 255, 0.85);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-weight: 600;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: 0 2px 10px rgba(30, 80, 30, 0.08);
}

.rules-toggle .btn-ghost:hover {
  background: rgba(255, 255, 255, 0.85);
  color: var(--positive);
}

/* ── Portal back link ── */
.portal-back {
  text-align: center;
  margin-top: 12px;
}
.btn-portal-back {
  display: inline-block;
  font-size: 0.82rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  padding: 10px 20px;
  transition: var(--transition);
}
.btn-portal-back:hover {
  color: #fff;
}

/* ============================
   MODAL
   ============================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 0.25s ease;
}

.modal-overlay.hidden {
  display: none;
}

.modal-content {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.95);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  max-width: 440px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 12px 48px rgba(30, 80, 30, 0.15), 0 1px 0 rgba(255,255,255,0.8) inset;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  position: relative;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border: 1.5px solid var(--border-light);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.7);
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
  background: #fff;
}

.modal-title {
  font-size: 1.3rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.modal-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 20px;
}

/* Rules modal */
.rules-modal-content {
  max-height: 80vh;
}

.rules-body {
  margin-top: 16px;
}

.rule-item {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.rule-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #16a34a, #22c55e);
  color: white;
  font-size: 0.8rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.rule-item p {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-secondary);
}

.rule-positive {
  color: var(--card-positive);
  font-weight: 700;
}

.rule-negative {
  color: var(--negative);
  font-weight: 700;
}

.rule-example {
  margin-top: 20px;
  padding: 16px;
  background: rgba(22, 163, 74, 0.05);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--positive);
}

.rule-example h3 {
  font-size: 0.85rem;
  color: var(--positive);
  margin-bottom: 8px;
}

.rule-example p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.7;
}

/* ============================
   GAME SCREEN
   ============================ */

.game-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.75);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 2px 16px rgba(30, 80, 30, 0.08);
  height: var(--header-height);
}

.hole-info {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.game-title-logo {
  font-family: 'M PLUS Rounded 1c', 'Outfit', sans-serif;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--positive);
}

.round-indicator {
  font-size: 0.82rem;
  font-weight: 800;
  padding: 4px 12px;
  border-radius: 20px;
  background: rgba(22, 163, 74, 0.1);
  border: 1.5px solid rgba(22, 163, 74, 0.25);
  color: var(--positive);
  letter-spacing: 0.04em;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.2;
}

.round-sub {
  font-size: 0.6rem;
  font-weight: 600;
  opacity: 0.75;
}

.round-indicator[data-half="second"] {
  background: rgba(124, 58, 237, 0.08);
  border-color: rgba(124, 58, 237, 0.25);
  color: #7c3aed;
}

/* 前半・後半切り替えボタン */
.btn-round-toggle.hidden {
  display: none;
}

.btn-round-toggle {
  padding: 6px 12px;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.7);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
  backdrop-filter: blur(8px);
}

.btn-round-toggle:hover {
  background: #fff;
  border-color: var(--positive);
  color: var(--positive);
  box-shadow: var(--shadow-soft);
}

.btn-round-toggle[data-current="second"] {
  border-color: rgba(124, 58, 237, 0.3);
  color: #7c3aed;
}

.btn-round-toggle[data-current="second"]:hover {
  border-color: #7c3aed;
  box-shadow: 0 2px 12px rgba(124, 58, 237, 0.1);
}

.hole-label {
  font-family: 'Outfit', sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.hole-number {
  font-family: 'Outfit', sans-serif;
  font-size: 2rem;
  font-weight: 900;
  color: var(--positive);
  line-height: 1;
}

.hole-total {
  font-family: 'Outfit', sans-serif;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-muted);
}

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

/* Player strip */
.player-strip {
  display: flex;
  gap: 6px;
  padding: 10px 16px;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--border-subtle);
  background: rgba(255, 255, 255, 0.4);
}

.player-strip::-webkit-scrollbar {
  display: none;
}

.player-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: var(--radius-xl);
  background: rgba(255, 255, 255, 0.7);
  border: 2px solid var(--chip-color, var(--border-subtle));
  flex-shrink: 0;
  cursor: pointer;
  transition: var(--transition);
}

.player-chip:hover {
  background: #fff;
  box-shadow: 0 2px 12px color-mix(in srgb, var(--chip-color) 20%, transparent);
}

.player-chip-name {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
}

.player-chip-count {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  font-weight: 700;
}

.count-positive {
  color: var(--card-positive);
}

.count-negative {
  color: var(--negative);
}

.count-separator {
  color: var(--text-muted);
  font-size: 0.65rem;
}

/* Cards area */
.cards-area {
  padding: 16px;
  padding-bottom: 100px;
}

.cards-section {
  margin-bottom: 24px;
}

.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  font-weight: 800;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--border-subtle);
  letter-spacing: 0.04em;
}

.section-title-positive {
  color: #2563eb;
}

.section-title-negative {
  color: var(--negative);
}

.section-icon {
  font-size: 1.1rem;
}

.section-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  letter-spacing: 0.05em;
}

.positive-badge {
  background: rgba(37, 99, 235, 0.08);
  color: var(--card-positive);
  border: 1px solid rgba(37, 99, 235, 0.2);
}

.negative-badge {
  background: rgba(220, 38, 38, 0.06);
  color: var(--negative);
  border: 1px solid rgba(220, 38, 38, 0.15);
}

/* Cards grid */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
}

/* Individual card */
.game-card {
  position: relative;
  padding: 14px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.8);
  background: rgba(255, 255, 255, 0.6);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  cursor: pointer;
  transition: var(--transition);
  overflow: hidden;
  user-select: none;
  box-shadow: 0 2px 12px rgba(30, 80, 30, 0.06);
}

.game-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  opacity: 0;
  transition: var(--transition);
}

.game-card.positive-card::before {
  background: var(--positive-gradient);
}

.game-card.negative-card::before {
  background: var(--negative-gradient);
}

.game-card:hover {
  transform: translateY(-3px);
  background: #fff;
  box-shadow: var(--shadow-card);
}

.game-card:hover::before {
  opacity: 1;
}

.game-card.positive-card:hover {
  border-color: rgba(22, 163, 74, 0.35);
  box-shadow: 0 6px 24px var(--positive-glow);
}

.game-card.negative-card:hover {
  border-color: rgba(220, 38, 38, 0.3);
  box-shadow: 0 6px 24px var(--negative-glow);
}

/* Card states: assigned */
.game-card.assigned {
  border-width: 2px;
}

.game-card.assigned::before {
  opacity: 1;
}

.game-card.assigned.positive-card {
  background: linear-gradient(180deg, rgba(22, 163, 74, 0.07), rgba(255, 255, 255, 0.9));
  border-color: rgba(22, 163, 74, 0.4);
}

.game-card.assigned.negative-card {
  background: linear-gradient(180deg, rgba(220, 38, 38, 0.06), rgba(255, 255, 255, 0.9));
  border-color: rgba(220, 38, 38, 0.35);
}

.card-emoji {
  display: none;
}

.card-name {
  font-size: 1.05rem;
  font-weight: 800;
  margin-bottom: 2px;
}

.positive-card .card-name {
  color: var(--card-positive);
}

.negative-card .card-name {
  color: var(--negative);
}

.card-desc {
  font-size: 0.65rem;
  color: var(--text-muted);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-owner {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.card-owner-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--owner-color);
}

.card-owner.hidden {
  display: none;
}

/* Pulse animation for assigned card */
@keyframes cardPulse {
  0% { box-shadow: 0 0 0 0 var(--pulse-color); }
  70% { box-shadow: 0 0 0 10px transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

.game-card.just-assigned {
  animation: cardPulse 0.8s ease-out;
}

/* Card with image indicator */
.game-card.has-image {
  position: relative;
}



/* ============================
   CARD IMAGE PREVIEW MODAL
   ============================ */

.card-image-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0);
  z-index: 1100;
  transition: background 0.4s ease;
}

.card-image-overlay.hidden {
  display: none;
}

.card-image-overlay.active {
  background: rgba(0, 0, 0, 0.4);
}

.card-image-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: min(420px, 92vw);
  height: 100vh;
  height: 100dvh;
  background: linear-gradient(180deg, #ffffff, #f0f7f0);
  border-left: 1px solid var(--border-light);
  box-shadow: -8px 0 40px rgba(0, 0, 0, 0.12);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.32, 0.72, 0, 1);
  z-index: 1101;
}

.card-image-overlay.active .card-image-panel {
  transform: translateX(0);
}

.card-image-close {
  position: absolute;
  top: 14px;
  left: 14px;
  width: 40px;
  height: 40px;
  border: 1.5px solid var(--border-light);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(8px);
  color: var(--text-primary);
  font-size: 1rem;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.card-image-close:hover {
  background: #fff;
  border-color: var(--text-muted);
}

.card-image-container {
  position: relative;
  width: 100%;
  flex-shrink: 0;
  overflow: hidden;
}

.card-image-img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
  opacity: 0;
  transform: scale(1.05);
  transition: opacity 0.5s ease 0.15s, transform 0.6s ease 0.15s;
}

.card-image-overlay.active .card-image-img {
  opacity: 1;
  transform: scale(1);
}

.card-image-info {
  padding: 20px;
  flex: 1;
}

.card-image-name {
  font-size: 1.5rem;
  font-weight: 900;
  margin-bottom: 6px;
  background: linear-gradient(135deg, #1a3a1a, #16a34a);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.card-image-type-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 20px;
  letter-spacing: 0.05em;
  margin-bottom: 10px;
}

.card-image-type-badge.type-positive {
  background: rgba(37, 99, 235, 0.08);
  color: var(--card-positive);
  border: 1px solid rgba(37, 99, 235, 0.2);
}

.card-image-type-badge.type-negative {
  background: rgba(220, 38, 38, 0.06);
  color: var(--negative);
  border: 1px solid rgba(220, 38, 38, 0.15);
}

.card-image-desc {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-top: 6px;
}

.card-image-owner {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 10px 14px;
  background: rgba(22, 163, 74, 0.04);
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.card-image-owner.hidden {
  display: none;
}

.card-image-owner-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.card-image-select-btn {
  margin: 16px 20px 28px;
  flex-shrink: 0;
}

/* ============================
   PLAYER SELECT MODAL
   ============================ */

.selected-card-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: rgba(22, 163, 74, 0.04);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.preview-emoji {
  font-size: 2rem;
}

.preview-info {
  flex: 1;
}

.preview-name {
  font-size: 1rem;
  font-weight: 700;
}

.preview-type {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.preview-type.type-positive {
  color: var(--card-positive);
}

.preview-type.type-negative {
  color: var(--negative);
}

.player-select-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.player-select-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border: 2px solid var(--border-subtle);
  border-left: 5px solid var(--btn-player-color, var(--border-light));
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.5);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
}

.player-select-btn:hover {
  background: #fff;
  box-shadow: 0 4px 16px color-mix(in srgb, var(--btn-player-color) 15%, transparent);
}

.player-select-btn:active {
  transform: scale(0.97);
}

.player-select-btn.current-owner {
  background: color-mix(in srgb, var(--btn-player-color) 6%, white);
}

.current-owner-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-left: auto;
}

.btn-unassign {
  width: 100%;
  text-align: center;
  font-size: 0.8rem;
}

/* ============================
   PLAYER DETAIL MODAL
   ============================ */

.player-detail-body {
  margin-top: 16px;
}

.player-detail-section {
  margin-bottom: 20px;
}

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

.player-detail-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
}

.player-detail-name {
  font-size: 1rem;
  font-weight: 700;
}

.player-detail-stats {
  display: flex;
  gap: 12px;
  margin-left: auto;
}

.stat-item {
  font-size: 0.75rem;
  font-weight: 700;
}

.player-detail-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.mini-card {
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}

.mini-card.mini-positive {
  background: rgba(22, 163, 74, 0.08);
  color: var(--positive);
  border: 1px solid rgba(22, 163, 74, 0.2);
}

.mini-card.mini-negative {
  background: rgba(220, 38, 38, 0.06);
  color: var(--negative);
  border: 1px solid rgba(220, 38, 38, 0.15);
}

.no-cards-msg {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ============================
   MENU MODAL
   ============================ */

.menu-buttons {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.resume-modal-content,
.confirm-modal-content {
  max-width: 380px;
  text-align: center;
}

.resume-modal-content .modal-subtitle,
.confirm-modal-content .modal-subtitle {
  margin-bottom: 4px;
}

/* ============================
   RESULT SCREEN
   ============================ */

.result-container {
  padding: 40px 20px 60px;
  max-width: 560px;
  margin: 0 auto;
}

.result-header {
  margin-bottom: 24px;
}

.result-hero-wrap {
  width: 100%;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-elevated);
}

.result-hero-img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
}

/* Rankings */
.result-rankings {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 32px;
}

.ranking-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.7);
  border: 1.5px solid var(--border-subtle);
  border-left-width: 5px;
  transition: var(--transition);
}

.ranking-card.rank-1 {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.1), rgba(255, 255, 255, 0.9));
  border-color: rgba(251, 191, 36, 0.35);
  box-shadow: 0 4px 20px rgba(251, 191, 36, 0.1);
}

.ranking-card.rank-2 {
  background: linear-gradient(135deg, rgba(156, 163, 175, 0.08), rgba(255, 255, 255, 0.9));
  border-color: rgba(156, 163, 175, 0.25);
}

.ranking-card.rank-3 {
  background: linear-gradient(135deg, rgba(180, 83, 9, 0.07), rgba(255, 255, 255, 0.9));
  border-color: rgba(180, 83, 9, 0.2);
}

.rank-position {
  font-family: 'M PLUS Rounded 1c', 'Outfit', sans-serif;
  font-size: 1.1rem;
  font-weight: 900;
  width: 48px;
  text-align: center;
  flex-shrink: 0;
  padding: 6px 4px;
  border-radius: var(--radius-sm);
  letter-spacing: 0.02em;
}

.rank-pos-1 { background: linear-gradient(135deg, #fef3c7, #fde68a); color: #92400e; border: 1.5px solid #f59e0b; }
.rank-pos-2 { background: linear-gradient(135deg, #f1f5f9, #e2e8f0); color: #475569; border: 1.5px solid #94a3b8; }
.rank-pos-3 { background: linear-gradient(135deg, #fef9e7, #fde8c8); color: #92400e; border: 1.5px solid #d97706; }
.rank-pos-4 { background: rgba(0,0,0,0.04); color: var(--text-muted); border: 1.5px solid var(--border-subtle); }

.rank-player-info {
  flex: 1;
}

.rank-player-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-primary);
}

.rank-card-counts {
  display: flex;
  gap: 8px;
  margin-top: 5px;
}

.rank-count {
  font-size: 0.76rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
}

.rank-count.count-positive {
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.2);
}

.rank-count.count-negative {
  background: rgba(220, 38, 38, 0.06);
  border: 1px solid rgba(220, 38, 38, 0.15);
}

.rank-score {
  font-family: 'Outfit', sans-serif;
  font-size: 1.8rem;
  font-weight: 900;
  flex-shrink: 0;
}

.rank-score.score-positive {
  color: var(--card-positive);
}

.rank-score.score-negative {
  color: var(--negative);
}

.rank-score.score-zero {
  color: var(--text-muted);
}

/* Result detail */
.result-detail {
  margin-bottom: 28px;
}

.result-player-section {
  margin-bottom: 20px;
  padding: 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.6);
  border: 1.5px solid var(--border-subtle);
}

.result-player-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.result-cards-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Result actions */
.result-actions {
  text-align: center;
}

.result-actions .btn-primary {
  max-width: 320px;
  margin: 0 auto;
}

/* ============================
   TOAST NOTIFICATIONS
   ============================ */

.toast-container {
  position: fixed;
  top: calc(var(--header-height) + 10px);
  right: 16px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 12px 18px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.95);
  border: 1.5px solid var(--border-light);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-elevated);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-primary);
  animation: toastIn 0.4s ease, toastOut 0.4s ease 2.2s forwards;
  max-width: 300px;
}

.toast-move {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast-arrow {
  color: var(--positive);
  font-weight: 700;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(40px) scale(0.9); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

@keyframes toastOut {
  from { opacity: 1; transform: translateX(0); }
  to { opacity: 0; transform: translateX(40px); }
}

/* ============================
   RESPONSIVE
   ============================ */

@media (max-width: 400px) {
  .cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .logo-title {
    font-size: 2.4rem;
  }

  .game-card {
    padding: 10px;
  }

  .card-emoji {
    display: none;
  }

  .card-name {
    font-size: 0.92rem;
  }

  .setup-card {
    padding: 20px 12px;
  }

  .name-input {
    padding: 10px 12px;
    font-size: 0.9rem;
  }

  .rate-input {
    width: 70px;
    font-size: 1rem;
  }

  .rate-preset-btn {
    padding: 6px 10px;
    font-size: 0.72rem;
  }
}

@media (min-width: 600px) {
  .cards-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (min-width: 900px) {
  .cards-grid {
    grid-template-columns: repeat(5, 1fr);
  }
}

/* ============================
   POINT RATE SETTING
   ============================ */

.point-rate-selector {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.point-rate-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.6);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
}

.rate-prefix {
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  flex-shrink: 0;
}

.rate-input {
  width: 90px;
  padding: 8px 10px;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.8);
  color: #b45309;
  font-family: 'Outfit', sans-serif;
  font-size: 1.2rem;
  font-weight: 800;
  text-align: center;
  transition: var(--transition);
  -moz-appearance: textfield;
}

.rate-input::-webkit-outer-spin-button,
.rate-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.rate-input:focus {
  outline: none;
  border-color: #f59e0b;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}

.rate-suffix {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.rate-presets {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.rate-preset-btn {
  padding: 8px 14px;
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.5);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  flex: 1;
  min-width: 60px;
  text-align: center;
}

.rate-preset-btn:hover {
  background: rgba(255, 255, 255, 0.85);
  border-color: #f59e0b;
}

.rate-preset-btn.active {
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.12), rgba(245, 158, 11, 0.06));
  border-color: #f59e0b;
  color: #b45309;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.1);
}

.rate-hint {
  font-size: 0.7rem;
  color: var(--text-muted);
  line-height: 1.5;
  padding-left: 2px;
}

/* ============================
   RESULT MONEY DISPLAY
   ============================ */

.rank-money {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 4px;
}

.money-amount {
  font-family: 'Outfit', sans-serif;
  font-size: 0.85rem;
  font-weight: 800;
  padding: 2px 10px;
  border-radius: 20px;
}

.money-plus {
  background: rgba(22, 163, 74, 0.08);
  color: var(--positive);
  border: 1px solid rgba(22, 163, 74, 0.2);
}

.money-minus {
  background: rgba(220, 38, 38, 0.06);
  color: var(--negative);
  border: 1px solid rgba(220, 38, 38, 0.15);
}

.money-zero {
  background: rgba(0, 0, 0, 0.03);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

.money-summary {
  margin-top: 24px;
  margin-bottom: 32px;
  padding: 20px;
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.06), rgba(255, 255, 255, 0.9));
  border: 1.5px solid rgba(251, 191, 36, 0.2);
}

.money-summary-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  font-weight: 700;
  color: #b45309;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(251, 191, 36, 0.15);
}

.money-summary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0 10px 12px;
  border-bottom: 1px solid var(--border-subtle);
  margin-left: -12px;
}

.money-summary-row:last-child {
  border-bottom: none;
}

.money-player-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.money-player-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.money-player-name {
  font-size: 0.9rem;
  font-weight: 600;
}

.money-result {
  font-family: 'Outfit', sans-serif;
  font-size: 1.1rem;
  font-weight: 800;
}

.money-result.money-win {
  color: var(--positive);
}

.money-result.money-lose {
  color: var(--negative);
}

.money-result.money-even {
  color: var(--text-muted);
}

.money-detail-text {
  font-size: 0.65rem;
  color: var(--text-muted);
  margin-top: 2px;
}

/* ============================
   ROUND BREAKDOWN
   ============================ */

.round-breakdown {
  display: flex;
  gap: 8px;
  margin-top: 6px;
}

.round-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  background: rgba(22, 163, 74, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
}

/* ============================
   SHARE SECTION
   ============================ */

.share-section {
  margin-top: 10px;
  margin-bottom: 30px;
  padding: 20px;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 1.5px solid var(--border-subtle);
  text-align: center;
}

.share-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 16px;
}

.share-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.btn-share {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: var(--transition);
  color: white;
  flex: 1;
  max-width: 160px;
  justify-content: center;
}

.btn-share-line {
  background: #06C755;
}

.btn-share-line:hover {
  background: #05a044;
  transform: translateY(-1px);
}

.btn-share-copy {
  background: rgba(255, 255, 255, 0.6);
  border: 1.5px solid var(--border-light);
  color: var(--text-primary);
}

.btn-share-copy:hover {
  background: #fff;
  border-color: var(--text-muted);
}

/* ============================
   CARD SELECT SCREEN
   ============================ */

.card-select-container {
  padding: 40px 16px 100px;
  max-width: 600px;
  margin: 0 auto;
}

.card-select-title {
  font-size: 1.8rem;
  font-weight: 900;
  text-align: center;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.card-select-subtitle {
  font-size: 0.85rem;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 32px;
}

.card-select-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-bottom: 20px;
}

.card-select-actions .btn-secondary {
  padding: 8px 16px;
  font-size: 0.8rem;
}

.card-select-section {
  margin-bottom: 30px;
}

.card-select-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.card-select-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.6);
  border: 1.5px solid var(--border-subtle);
  cursor: pointer;
  transition: var(--transition);
  user-select: none;
}

.card-select-item:hover {
  background: #fff;
  box-shadow: var(--shadow-soft);
}

.card-select-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--positive);
  cursor: pointer;
}

.card-select-emoji {
  display: none;
}

.card-select-name {
  font-size: 1.05rem;
  font-weight: 700;
}

.select-positive .card-select-name {
  color: var(--card-positive);
}

.select-negative .card-select-name {
  color: var(--negative);
}

.select-positive input[type="checkbox"]:checked + .card-select-emoji + .card-select-name {
  color: var(--card-positive);
}

/* Card select item: label part */
.card-select-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  flex: 1;
  min-width: 0;
}

/* Point stepper */
.card-point-stepper {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  justify-content: center;
}

.point-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1.5px solid rgba(0, 0, 0, 0.15);
  background: #fff;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  padding: 0;
  transition: background 0.15s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
}

.point-btn:active {
  transform: scale(0.9);
  background: #f0f0f0;
}

.point-value {
  min-width: 36px;
  text-align: center;
  font-size: 0.85rem;
  font-weight: 800;
  border-radius: 6px;
  padding: 3px 4px;
}

.point-value.point-positive {
  color: var(--card-positive);
  background: rgba(37, 99, 235, 0.08);
}

.point-value.point-negative {
  color: var(--negative);
  background: rgba(180, 50, 50, 0.08);
}

/* Reorganize card-select-item to vertical layout */
.card-select-item {
  flex-direction: column !important;
  align-items: stretch !important;
  gap: 0 !important;
}

.card-select-bottom-actions {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 -4px 20px rgba(30, 80, 30, 0.08);
  display: flex;
  gap: 10px;
  z-index: 100;
  max-width: 600px;
  margin: 0 auto;
}

.card-select-bottom-actions .btn-primary {
  flex: 2;
}

.card-select-bottom-actions .btn-secondary {
  flex: 1;
}

.game-bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255, 255, 255, 0.6);
  box-shadow: 0 -4px 20px rgba(30, 80, 30, 0.08);
  z-index: 99;
}

.btn-finish-game {
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
}

.btn-half-next {
  width: 100%;
  max-width: 400px;
  margin: 0 auto;
  background: linear-gradient(135deg, #7c3aed, #a855f7) !important;
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.25) !important;
}

.btn-half-next:hover {
  box-shadow: 0 6px 24px rgba(124, 58, 237, 0.35) !important;
}

/* ============================
   CUSTOM CARD SECTION
   ============================ */

.section-title-custom {
  color: #b45309;
}

.custom-badge {
  background: rgba(245, 158, 11, 0.1);
  color: #b45309;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.btn-add-custom {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  margin-top: 14px;
  padding: 14px 18px;
  border: 2px dashed rgba(245, 158, 11, 0.4);
  border-radius: var(--radius-md);
  background: rgba(245, 158, 11, 0.04);
  color: #b45309;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  justify-content: center;
}

.btn-add-custom:hover {
  background: rgba(245, 158, 11, 0.08);
  border-color: rgba(245, 158, 11, 0.7);
  box-shadow: 0 2px 12px rgba(245, 158, 11, 0.1);
}

.btn-add-custom-icon {
  font-size: 1rem;
  line-height: 1;
}

/* Custom card actions (edit/delete buttons under card) */
.custom-card-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border-subtle);
}

.btn-custom-edit,
.btn-custom-delete {
  flex: 1;
  padding: 5px 8px;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  border: 1.5px solid;
}

.btn-custom-edit {
  background: rgba(37, 99, 235, 0.05);
  color: var(--card-positive);
  border-color: rgba(37, 99, 235, 0.2);
}

.btn-custom-edit:hover {
  background: rgba(37, 99, 235, 0.12);
  border-color: var(--card-positive);
}

.btn-custom-delete {
  background: rgba(220, 38, 38, 0.04);
  color: var(--negative);
  border-color: rgba(220, 38, 38, 0.2);
}

.btn-custom-delete:hover {
  background: rgba(220, 38, 38, 0.1);
  border-color: var(--negative);
}

/* ============================
   CUSTOM CARD MODAL
   ============================ */

.custom-card-modal-content {
  max-height: 90vh;
  overflow-y: auto;
}

.custom-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-bottom: 8px;
}

.custom-form-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.custom-form-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
  letter-spacing: 0.06em;
}

/* Type selector */
.custom-type-selector {
  display: flex;
  gap: 10px;
}

.custom-type-btn {
  flex: 1;
  padding: 13px 12px;
  border: 2px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.5);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  letter-spacing: 0.03em;
}

.custom-type-btn:hover {
  background: rgba(255, 255, 255, 0.85);
}

.custom-type-btn[data-type="positive"].active {
  background: rgba(37, 99, 235, 0.08);
  border-color: var(--card-positive);
  color: var(--card-positive);
}

.custom-type-btn[data-type="negative"].active {
  background: rgba(220, 38, 38, 0.07);
  border-color: var(--negative);
  color: var(--negative);
}

/* Text input */
.custom-text-input {
  width: 100%;
  padding: 13px 14px;
  border: 2px solid var(--border-light);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.7);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  transition: var(--transition);
}

.custom-text-input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

.custom-text-input:focus {
  outline: none;
  background: #fff;
  border-color: var(--positive);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.12);
}

/* Point stepper in modal */
.custom-point-stepper {
  display: flex;
  align-items: center;
  gap: 10px;
}

.custom-point-stepper .point-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
}

.custom-point-stepper .point-value {
  min-width: 52px;
  font-size: 1.1rem;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
}

/* ============================
   MOBILE ADJUSTMENTS: CARD IMAGE POPUP
   ============================ */
@media (max-width: 600px) {
  .card-image-container {
    max-height: 42dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.02);
  }

  .card-image-img {
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 42dvh;
    object-fit: contain;
    margin: 0 auto;
  }

  .card-image-info {
    padding: 14px 18px 6px;
  }

  .card-image-name {
    font-size: 1.2rem;
    margin-bottom: 4px;
  }

  .card-image-type-badge {
    margin-bottom: 8px;
  }

  .card-image-desc {
    font-size: 0.85rem;
    line-height: 1.5;
  }

  .card-image-owner {
    margin-top: 10px;
    padding: 8px 12px;
    font-size: 0.78rem;
  }

  .card-image-select-btn {
    margin: 10px 16px 14px;
  }
}

/* Even more compact for very short viewports (landscape phones, small devices) */
@media (max-width: 600px) and (max-height: 680px) {
  .card-image-container,
  .card-image-img {
    max-height: 36dvh;
  }

  .card-image-info {
    padding: 10px 16px 4px;
  }

  .card-image-name {
    font-size: 1.1rem;
  }

  .card-image-desc {
    font-size: 0.82rem;
  }

  .card-image-select-btn {
    margin: 8px 14px 12px;
  }
}

/* ============================
   Multiplayer / Room UI
   ============================ */

/* モード選択 */
.mode-select-card {
  background: var(--bg-card);
  border-radius: 20px;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.08);
  margin-bottom: 16px;
}

.mode-select-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text-primary);
  text-align: center;
  margin: 0 0 4px;
}

.btn-mode {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-secondary);
  border: 2px solid transparent;
  border-radius: 14px;
  padding: 14px 18px;
  cursor: pointer;
  text-align: left;
  transition: all 0.18s;
}

.btn-mode:hover {
  background: #fff;
  border-color: var(--positive);
  box-shadow: 0 2px 12px var(--positive-glow);
}

.btn-mode-primary {
  background: var(--positive-gradient);
  color: #fff;
}

.btn-mode-primary:hover {
  opacity: 0.92;
  border-color: transparent;
}

.btn-mode-secondary {
  background: linear-gradient(135deg, #2563eb, #60a5fa);
  color: #fff;
}

.btn-mode-secondary:hover {
  opacity: 0.92;
  border-color: transparent;
}

.btn-mode-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
}

.btn-mode-label {
  font-size: 1rem;
  font-weight: 800;
  display: block;
}

.btn-mode-desc {
  font-size: 0.78rem;
  opacity: 0.8;
  display: block;
}

/* ルーム参加 */
.room-code-input-wrap {
  display: flex;
  justify-content: center;
  margin: 12px 0;
}

.room-code-input {
  font-size: 2.2rem;
  font-weight: 900;
  letter-spacing: 0.3em;
  text-align: center;
  width: 180px;
  padding: 12px 16px;
  border: 3px solid var(--positive);
  border-radius: 16px;
  background: #fff;
  color: var(--text-primary);
  outline: none;
}

.room-code-input:focus {
  box-shadow: 0 0 0 3px var(--positive-glow);
}

.join-error {
  color: #dc2626;
  font-size: 0.88rem;
  text-align: center;
  background: #fef2f2;
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 8px;
}

/* 待機画面 */
.room-code-display-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin: 12px 0 16px;
}

.room-code-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.room-code-display {
  font-size: 2.8rem;
  font-weight: 900;
  letter-spacing: 0.25em;
  color: var(--positive);
}

.waiting-spinner {
  width: 36px;
  height: 36px;
  border: 4px solid var(--positive-light);
  border-top-color: var(--positive);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 16px auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.waiting-players-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 8px;
}

/* ゲーム画面のルームコードバッジ */
.room-code-badge {
  display: inline-block;
  background: var(--positive);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  padding: 2px 8px;
  border-radius: 20px;
  margin-left: 6px;
  vertical-align: middle;
}
