:root {
  --bg1: #fff4e0;
  --bg2: #ffe0ec;
  --primary: #ff5d8f;
  --primary-dark: #e8447a;
  --accent: #3fa9f5;
  --accent2: #ffb347;
  --accent3: #5ede7c;
  --ink: #33293f;
  --card-bg: #ffffff;
  --card-border: #f0d9e8;
  --shadow: 0 6px 18px rgba(120, 60, 90, 0.15);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  min-height: 100%;
  font-family: "Hiragino Maru Gothic ProN", "Rounded Mplus 1c", "Yu Gothic", sans-serif;
  background: linear-gradient(160deg, var(--bg1), var(--bg2));
  color: var(--ink);
  overflow-x: hidden;
}

.screen {
  display: none;
  min-height: 100vh;
  padding: 16px;
  flex-direction: column;
  align-items: center;
}
.screen.show { display: flex; }

.btn {
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 14px;
  border: 2px solid var(--card-border);
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(0,0,0,0.06);
  transition: transform .1s ease, box-shadow .1s ease;
}
.btn:hover { transform: translateY(-2px); }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.btn-lg { font-size: 18px; padding: 14px 26px; border-radius: 18px; }
.btn-primary {
  background: linear-gradient(135deg, var(--primary), #ff8fb3);
  border-color: var(--primary-dark);
  color: #fff;
  box-shadow: 0 4px 0 var(--primary-dark);
}
.mode-btn.active {
  background: linear-gradient(135deg, var(--accent), #7fc4f7);
  color: #fff;
  border-color: #2b83c9;
}

/* ---- タイトル ---- */
.title-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 18px;
}
.title-logo {
  font-size: 44px;
  font-weight: 900;
  color: var(--primary);
  text-shadow: 3px 3px 0 #fff, 5px 5px 0 rgba(0,0,0,0.08);
}
.title-logo span { color: var(--accent2); }
.title-sub { font-size: 16px; opacity: .8; font-weight: 700; }
.title-buttons { display: flex; flex-direction: column; gap: 12px; width: min(320px, 80vw); }
.title-progress { font-size: 13px; opacity: .7; font-weight: 700; }
.version-footer { position: fixed; bottom: 8px; right: 12px; font-size: 12px; opacity: .5; }

/* ---- 共通パネル ---- */
.panel {
  width: min(920px, 100%);
  background: var(--card-bg);
  border-radius: 22px;
  padding: 20px;
  box-shadow: var(--shadow);
  margin: 10px auto 40px;
}
.panel h2 { color: var(--primary); margin: 18px 0 10px; }
.panel h3 { color: var(--accent); margin: 16px 0 8px; }
.hint { font-size: 13px; opacity: .75; margin: 4px 0 10px; }

/* ---- 選択カード ---- */
.sel-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 8px; }
.sel-card {
  border: 2px solid var(--card-border);
  border-radius: 16px;
  padding: 12px;
  cursor: pointer;
  background: #fffaf5;
  transition: transform .1s ease, border-color .1s ease;
}
.sel-card:hover { transform: translateY(-2px); }
.sel-card.selected { border-color: var(--primary); background: #fff0f5; box-shadow: 0 0 0 3px rgba(255,93,143,0.2); }
.sel-card.locked { opacity: .55; cursor: not-allowed; }
.sel-card-icon { font-size: 26px; }
.sel-card-title { font-weight: 800; margin: 4px 0 2px; }
.sel-card-desc { font-size: 12px; opacity: .8; line-height: 1.4; }
.sel-card-meta { font-size: 11px; opacity: .6; margin-top: 6px; }
.mode-toggle { display: flex; gap: 10px; margin: 10px 0; }

/* ---- ゲーム画面 ---- */
.game-layout {
  width: 100%;
  max-width: 1100px;
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: center;
}
.game-main { flex: 3; min-width: 300px; }
.game-side { flex: 1; min-width: 220px; }

.turn-bar {
  background: #fff;
  border-radius: 16px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
  font-weight: 800;
}
#turn-banner.thinking { color: var(--accent); animation: think-pulse 1s ease-in-out infinite; }
@keyframes think-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .55; } }
.spin-area { display: flex; align-items: center; gap: 10px; }
.spin-num {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--accent2); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 900;
  box-shadow: 0 3px 0 #d98d1f;
}

.board {
  position: relative;
  background: repeating-linear-gradient(135deg, #fbf3e6, #fbf3e6 14px, #f7ecd9 14px, #f7ecd9 28px);
  border: 4px solid #fff;
  border-radius: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 10px;
  overflow: hidden;
}
.board-road-svg { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.board-road-outline { fill: none; stroke: #ffffff; stroke-width: 34px; stroke-linecap: round; stroke-linejoin: round; }
.board-road { fill: none; stroke: #ffd9a8; stroke-width: 24px; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 2px 22px; }

.sq {
  position: absolute;
  transform: translate(-50%, -50%);
  width: clamp(44px, 8vw, 64px);
  height: clamp(44px, 8vw, 64px);
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  text-align: center;
  color: #fff;
  border: 3px solid rgba(255,255,255,0.85);
  box-shadow: 0 4px 0 rgba(0,0,0,0.12), 0 6px 10px rgba(0,0,0,0.12);
  cursor: default;
  z-index: 1;
}
.sq-icon { font-size: clamp(15px, 3vw, 22px); line-height: 1; }
.sq-num { position: absolute; top: -6px; left: -6px; font-size: 9px; opacity: .85; background: #fff; color: #666; border-radius: 50%; width: 15px; height: 15px; display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.sq-pawns {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  justify-content: center;
  width: 46px;
  z-index: 2;
  pointer-events: none;
}
.pawn {
  width: 18px; height: 18px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; color: #fff;
  border: 2px solid #fff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.35);
  transition: left .35s ease, top .35s ease;
}

.sq-start { background: #6bcB77; }
.sq-salary { background: #ffb347; }
.sq-bonus { background: #ffd23f; color: #664c00; }
.sq-expense { background: #9a9a9a; }
.sq-career { background: #3fa9f5; }
.sq-marriage { background: #ff8fb3; }
.sq-child { background: #ffc6de; color: #6b2d4a; }
.sq-house { background: #b07a4a; }
.sq-stock { background: #5ede7c; color: #14522a; }
.sq-insurance { background: #7c9bff; }
.sq-chance { background: #6bd6d0; color: #0a4c48; }
.sq-trouble { background: #ff6b6b; }
.sq-gamble { background: #c46bff; }
.sq-rest { background: #d9cfc1; color: #4a3f30; }
.sq-goal { background: linear-gradient(135deg,#ff5d8f,#ffb347); }

.log-panel { background: #fff; border-radius: 16px; padding: 10px 14px; box-shadow: var(--shadow); max-height: 200px; overflow-y: auto; }
.log-panel h4 { margin: 0 0 6px; color: var(--accent); }
.log-line { font-size: 12px; padding: 2px 0; border-bottom: 1px dashed #eee; }

/* ---- プレイヤーパネル ---- */
.player-panel {
  background: #fff;
  border: 2px solid var(--card-border);
  border-radius: 14px;
  padding: 10px;
  margin-bottom: 8px;
  box-shadow: var(--shadow);
  opacity: .8;
}
.player-panel.active { opacity: 1; border-width: 3px; transform: scale(1.02); }
.player-panel.finished { opacity: .6; }
.pp-head { display: flex; align-items: center; gap: 6px; font-weight: 800; font-size: 13px; }
.pp-dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.pp-rank { margin-left: auto; background: var(--accent2); color: #fff; padding: 1px 8px; border-radius: 10px; font-size: 11px; }
.pp-money { font-weight: 900; color: var(--primary); margin: 4px 0; }
.pp-icons { font-size: 15px; display: flex; gap: 6px; }
.pp-none { font-size: 11px; opacity: .5; }
.pp-pos { font-size: 11px; opacity: .6; margin-top: 3px; }

/* ---- モーダル ---- */
#modal-overlay {
  position: fixed; inset: 0; background: rgba(40,20,30,0.5);
  display: none; align-items: center; justify-content: center; z-index: 100; padding: 16px;
}
#modal-overlay.show { display: flex; }
.modal-box { background: #fff; border-radius: 20px; padding: 22px; width: min(420px, 100%); box-shadow: var(--shadow); text-align: center; }
.modal-box h3 { color: var(--primary); margin-top: 0; }
.modal-buttons { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }

/* ---- 結果画面 ---- */
.result-table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.result-table th, .result-table td { padding: 8px; border-bottom: 1px solid #eee; text-align: center; font-size: 13px; }
.result-table .me-row { background: #fff0f5; font-weight: 800; }
.result-progress { margin-top: 14px; font-weight: 700; color: var(--accent); }
.result-buttons { display: flex; gap: 10px; margin-top: 18px; justify-content: center; flex-wrap: wrap; }

/* ---- 実績 ---- */
.ach-category h3 { display: flex; justify-content: space-between; align-items: center; }
.ach-cat-count { font-size: 12px; background: var(--accent); color: #fff; padding: 2px 10px; border-radius: 10px; }
.ach-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-bottom: 14px; }
.ach-card { border-radius: 14px; padding: 10px; text-align: center; border: 2px solid var(--card-border); }
.ach-card.unlocked { background: #fff8ea; border-color: var(--accent2); }
.ach-card.locked { background: #f3f3f3; opacity: .55; }
.ach-card-icon { font-size: 24px; }
.ach-card-title { font-weight: 800; font-size: 12px; margin: 4px 0 2px; }
.ach-card-desc { font-size: 10px; opacity: .8; line-height: 1.3; }

/* ---- 記録 ---- */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat-box { background: #fff8ea; border-radius: 14px; padding: 14px; text-align: center; box-shadow: var(--shadow); }
.stat-box.wide { grid-column: 1 / -1; }
.stat-num { font-size: 24px; font-weight: 900; color: var(--primary); }
.stat-label { font-size: 12px; opacity: .8; margin-top: 4px; }

/* ---- トースト ---- */
#toast-area { position: fixed; top: 10px; right: 10px; z-index: 200; display: flex; flex-direction: column; gap: 8px; max-width: min(320px, 92vw); }
.ach-toast {
  display: flex; align-items: center; gap: 10px;
  background: #fff; border: 2px solid var(--accent2);
  border-radius: 14px; padding: 10px 14px; box-shadow: var(--shadow);
  transform: translateX(120%); opacity: 0; transition: transform .35s ease, opacity .35s ease;
}
.ach-toast.show { transform: translateX(0); opacity: 1; }
.ach-toast-icon { font-size: 24px; }
.ach-toast-title { font-weight: 800; font-size: 13px; color: var(--primary); }
.ach-toast-desc { font-size: 11px; opacity: .8; }

/* ---- レスポンシブ ---- */
@media (max-width: 720px) {
  .title-logo { font-size: 32px; }
  .game-side { order: -1; }
}
