/* ============================================================
   ベーススタイル（スマートフォン基準 / mobile-first）
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: "Hiragino Kaku Gothic ProN", "Meiryo", sans-serif;
  background: #1a3a5c;
  color: #fff;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 10px 24px;
}
h1 {
  font-size: 1.3rem;
  margin-bottom: 2px;
  letter-spacing: 0.06em;
  text-shadow: 0 2px 6px rgba(0,0,0,0.5);
}
.subtitle {
  font-size: 0.78rem;
  color: #aac8e8;
  margin-bottom: 14px;
}

/* ===== メインカード ===== */
.roulette-box {
  background: #0d2540;
  border: 2px solid #3a7bd5;
  border-radius: 14px;
  padding: 16px 14px;
  width: 100%;
  max-width: 420px;
  text-align: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

/* ===== 画像枠（スマホ：160×220） ===== */
.sign-frame {
  width: 160px;
  height: 220px;
  margin: 0 auto 12px;
  border: 2px solid #3a7bd5;
  border-radius: 8px;
  overflow: hidden;
  background: #0a1e35;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  position: relative;
}
.sign-frame.spinning { cursor: default; }
.sign-frame:not(.spinning):active .zoom-hint,
.sign-frame:not(.spinning):hover  .zoom-hint { opacity: 1; }
.zoom-hint {
  position: absolute;
  bottom: 5px;
  right: 6px;
  font-size: 0.65rem;
  color: rgba(255,255,255,0.6);
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  background: rgba(0,0,0,0.4);
  padding: 2px 5px;
  border-radius: 4px;
}
.sign-frame img {
  width: 160px;
  height: 220px;
  object-fit: contain;
}

/* ===== 市町村名 ===== */
.muni-name {
  font-size: 1.35rem;
  font-weight: bold;
  letter-spacing: 0.08em;
  margin-bottom: 2px;
  min-height: 1.8rem;
  color: #e8f4ff;
}
.muni-sub {
  font-size: 0.78rem;
  color: #7aafd4;
  margin-bottom: 12px;
  min-height: 1.1rem;
}

/* ===== 速度調整 ===== */
.speed-section { margin-bottom: 12px; text-align: left; }
.speed-radios {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: center;
}
.speed-radio { display: none; }
.speed-label {
  padding: 5px 11px;
  font-size: 0.78rem;
  border: 1px solid #2a5080;
  border-radius: 20px;
  background: #0d2540;
  color: #7aafd4;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  user-select: none;
}
.speed-radio:checked + .speed-label {
  background: #3a7bd5;
  color: #fff;
  border-color: #3a7bd5;
}

/* ===== 除外設定行 ===== */
.exclude-info {
  font-size: 0.72rem;
  color: #e07070;
  white-space: nowrap;
}
.exclude-auto-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.72rem;
  color: #7aafd4;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.exclude-auto-label input[type="checkbox"] { cursor: pointer; accent-color: #3a7bd5; }

/* ===== 振興局フィルター ===== */
.filter-section { margin-bottom: 12px; text-align: left; }
.filter-label {
  font-size: 0.75rem;
  color: #7aafd4;
  margin-bottom: 5px;
}
.filter-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  flex-wrap: wrap;
}
.filter-select {
  background: #0d2540;
  color: #e8f4ff;
  border: 1px solid #3a7bd5;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 0.8rem;
  cursor: pointer;
  outline: none;
  flex-shrink: 0;
}
.filter-select:focus { border-color: #6aa3e8; }
.toggle-group {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  flex: 1;
}
.toggle-btn {
  padding: 5px 10px;
  font-size: 0.75rem;
  border: 1px solid #2a5080;
  border-radius: 20px;
  background: #0d2540;
  color: #7aafd4;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  user-select: none;
  white-space: nowrap;
}
.toggle-btn.active {
  background: #3a7bd5;
  color: #fff;
  border-color: #3a7bd5;
}

/* ===== START/STOPボタン ===== */
.btn {
  display: block;
  width: 100%;
  padding: 14px 0;
  font-size: 1.2rem;
  font-weight: bold;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  letter-spacing: 0.2em;
  transition: background 0.2s, transform 0.1s;
  user-select: none;
}
.btn-start { background: #3a7bd5; color: #fff; }
.btn-start:active { background: #2a63bb; transform: scale(0.98); }
.btn-stop {
  background: #d53a3a; color: #fff;
  animation: pulse 0.8s ease-in-out infinite alternate;
}
.btn-stop:active { background: #bb2a2a; }
@keyframes pulse {
  from { box-shadow: 0 0 0 0 rgba(213,58,58,0.6); }
  to   { box-shadow: 0 0 0 10px rgba(213,58,58,0); }
}

/* ===== 一覧ボタン ===== */
.btn-list {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 10px 0;
  font-size: 0.88rem;
  border: 1px solid #3a7bd5;
  border-radius: 8px;
  background: transparent;
  color: #7aafd4;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.btn-list:active { background: #1a3a5c; color: #e8f4ff; }

.img-credit { margin-top: 12px; font-size: 0.68rem; color: #4a7aa0; }
.img-credit a { color: #5a9aca; }

/* ===== 履歴 ===== */
.history-section {
  width: 100%;
  max-width: 420px;
  margin-top: 16px;
}
.history-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  min-height: 1.8rem;
}
.history-header-right {
  display: flex;
  align-items: center;
  gap: 8px;
}
.history-title {
  font-size: 0.8rem;
  color: #aac8e8;
  cursor: pointer;
  user-select: none;
}
.history-title:hover { color: #e8f4ff; }
.btn-clear {
  padding: 3px 10px;
  font-size: 0.72rem;
  border: 1px solid #4a7aa0;
  border-radius: 20px;
  background: transparent;
  color: #7aafd4;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  user-select: none;
}
.btn-clear:active { background: #1a3a5c; color: #e8f4ff; }
.history-list { display: flex; flex-wrap: wrap; gap: 5px; }
.history-chip {
  background: #0d2540;
  border: 1px solid #2a5080;
  border-radius: 20px;
  padding: 3px 10px;
  font-size: 0.75rem;
  color: #aac8e8;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.history-chip:hover  { background: #122d50; border-color: #3a7bd5; color: #e8f4ff; }
.history-chip:active { background: #1a3a5c; }

/* ===== モーダル共通 ===== */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 100;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open { display: flex; }

/* ===== 拡大モーダル ===== */
.zoom-modal-inner {
  position: relative;
  max-width: 92vw;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.zoom-modal-inner img {
  max-width: 88vw;
  max-height: 75vh;
  object-fit: contain;
  border-radius: 6px;
  box-shadow: 0 4px 32px rgba(0,0,0,0.6);
}
.zoom-modal-name {
  font-size: 1.2rem;
  font-weight: bold;
  color: #e8f4ff;
  letter-spacing: 0.08em;
}
.zoom-modal-sub { font-size: 0.8rem; color: #7aafd4; }
.modal-close {
  position: absolute;
  top: -38px;
  right: 0;
  background: none;
  border: none;
  color: #aac8e8;
  font-size: 1.8rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
}
/* 拡大モーダル 除外ボタン（左上） */
.zoom-exclude-btn {
  position: absolute;
  top: -38px;
  left: 0;
  display: none;
  padding: 4px 12px;
  font-size: 0.78rem;
  border: 1px solid #4a7aa0;
  border-radius: 20px;
  background: transparent;
  color: #7aafd4;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  user-select: none;
  white-space: nowrap;
  line-height: 1.4;
}
.zoom-exclude-btn.is-excluded {
  background: #c0392b;
  color: #fff;
  border-color: #c0392b;
}
.zoom-exclude-btn:active { opacity: 0.8; }

/* ===== 一覧モーダル ===== */
.list-modal-inner {
  background: #0d2540;
  border: 2px solid #3a7bd5;
  border-radius: 12px;
  padding: 0 12px 16px;   /* padding-top は sticky ヘッダー側で持つ */
  width: 96vw;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}
/* 一覧モーダル sticky ヘッダー */
.list-modal-sticky {
  position: sticky;
  top: 0;
  background: #0d2540;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0 10px;   /* 左右は親の padding に任せる */
  border-bottom: 1px solid #1e3f60;
  margin-bottom: 4px;
}
.list-modal-sticky h2 {
  font-size: 1.05rem;
  color: #e8f4ff;
  letter-spacing: 0.06em;
}
.list-modal-sticky-btns {
  display: flex;
  align-items: center;
  gap: 8px;
}
.btn-exclude-mode {
  padding: 4px 12px;
  font-size: 0.75rem;
  border: 1px solid #4a7aa0;
  border-radius: 20px;
  background: transparent;
  color: #7aafd4;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  user-select: none;
  white-space: nowrap;
}
.btn-exclude-mode.active { background: #c0392b; color: #fff; border-color: #c0392b; }
.btn-exclude-mode:active  { opacity: 0.8; }
.btn-exclude-clear {
  padding: 4px 10px;
  font-size: 0.75rem;
  border: 1px solid #c0392b;
  border-radius: 20px;
  background: transparent;
  color: #e07070;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  user-select: none;
  white-space: nowrap;
}
.btn-exclude-clear:active { background: #c0392b; color: #fff; }
.list-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.list-card {
  background: #0a1e35;
  border: 1px solid #2a5080;
  border-radius: 8px;
  padding: 6px 4px 5px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.list-card:active { border-color: #3a7bd5; background: #122d50; }
.list-card img {
  width: 100%;
  height: 72px;
  object-fit: contain;
  display: block;
  margin-bottom: 4px;
}
.list-card-name { font-size: 0.7rem; color: #e8f4ff; line-height: 1.3; }
.list-card-sub  { font-size: 0.6rem; color: #7aafd4; }
/* 除外済みカード */
.list-card.excluded {
  opacity: 0.4;
  border-color: #c0392b;
  position: relative;
}
.exclude-badge {
  position: absolute;
  top: 3px;
  right: 4px;
  font-size: 0.7rem;
  color: #e07070;
  font-weight: bold;
  line-height: 1;
}
.list-modal-close {
  background: none;
  border: none;
  color: #aac8e8;
  font-size: 1.8rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px;
  flex-shrink: 0;
}

/* ============================================================
   タブレット横画面（768px〜）
   ============================================================ */
@media (min-width: 768px) {
  body { padding: 20px 16px 32px; }
  h1 { font-size: 1.5rem; }
  .subtitle { font-size: 0.83rem; margin-bottom: 20px; }
  .roulette-box { max-width: 500px; padding: 22px 24px; }
  .sign-frame { width: 200px; height: 275px; }
  .sign-frame img { width: 200px; height: 275px; }
  .muni-name { font-size: 1.5rem; }
  .muni-sub  { font-size: 0.83rem; }
  .btn { padding: 13px 0; font-size: 1.15rem; }
  .btn-list { padding: 9px 0; }
  .history-section { max-width: 500px; }
  .list-modal-inner { width: min(94vw, 680px); padding: 0 18px 20px; }
  .list-modal-sticky { padding: 20px 0 10px; }
  .list-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
  .list-card img { height: 80px; }
}

/* ============================================================
   PC（1024px〜）
   ============================================================ */
@media (min-width: 1024px) {
  body { padding: 28px 20px 40px; }
  h1 { font-size: 1.6rem; }
  .roulette-box { max-width: 540px; padding: 28px 32px; }
  .sign-frame { width: 240px; height: 330px; }
  .sign-frame img { width: 240px; height: 330px; }
  .btn { padding: 14px 0; border-radius: 8px; }
  .btn-start:hover { background: #2a63bb; }
  .btn-list:hover  { background: #1a3a5c; color: #e8f4ff; }
  .btn-clear:hover { background: #1a3a5c; color: #e8f4ff; }
  .list-modal-inner { width: min(92vw, 900px); }
  .list-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
  .list-card img { height: 90px; }
  .list-card:hover { border-color: #3a7bd5; background: #122d50; }
}
