/* ======================== */
/* リセット                 */
/* ======================== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

/* ======================== */
/* 変数                     */
/* ======================== */
:root {
  --bg:        #0e0e0e;
  --bg-card:   #1a1a1a;
  --bg-input:  #111;
  --bg-btn:    #222;
  --border:    #2a2a2a;
  --border-hi: #333;
  --text:      #e8e8e8;
  --text-sub:  #aaa;
  --text-dim:  #555;
  --green:     #4caf50;
  --red:       #f44336;
  --orange:    #ff9100;
  --white:     #e8e8e8;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
}

/* ======================== */
/* ベース                   */
/* ======================== */
html {
  touch-action: manipulation;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans JP", sans-serif;
  min-height: 100%;
  overflow-x: hidden;
  line-height: 1.5;
  padding-bottom: 118px;
}

/* ======================== */
/* フッター広告             */
/* ======================== */
.footer-ad-band {
  position: fixed;
  left: 50%;
  bottom: calc(14px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 90;
  width: min(calc(100% - 20px), 680px);
  min-height: 54px;
  margin: 0;
  background:
    linear-gradient(135deg, rgba(76, 175, 80, 0.08), transparent 38%),
    #151515;
  border: 1px solid #2b2b2b;
  border-radius: var(--radius-md);
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #666;
  font-family: "Noto Sans JP", sans-serif;
  font-size: 11px;
  letter-spacing: 1px;
  pointer-events: none;
}

.footer-ad-band span {
  font-family: "DM Mono", monospace;
  font-size: 9px;
  color: var(--green);
  letter-spacing: 2px;
  margin-right: 8px;
}

.footer-ad-band.ad-live {
  background: transparent;
  border: none;
  box-shadow: none;
  padding: 0;
  pointer-events: auto;
}

.footer-ad-band .adsbygoogle {
  width: 100%;
  min-height: 54px;
}

.interstitial-ad-overlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.9);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.interstitial-ad-overlay.show {
  opacity: 1;
  pointer-events: all;
}

.interstitial-ad-panel {
  width: 100%;
  max-width: 380px;
  background: #1a1a1a;
  border: 1px solid #2a2a2a;
  border-radius: var(--radius-lg);
  padding: 18px;
  box-shadow: 0 18px 52px rgba(0, 0, 0, 0.5);
}

.interstitial-ad-label {
  font-family: "DM Mono", monospace;
  font-size: 10px;
  color: var(--green);
  letter-spacing: 2px;
  margin-bottom: 10px;
}

.interstitial-ad-slot {
  min-height: 220px;
  background:
    linear-gradient(135deg, rgba(76, 175, 80, 0.08), transparent 40%),
    #111;
  border: 1px solid #303030;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #666;
  font-size: 13px;
  line-height: 1.8;
  padding: 18px;
  margin-bottom: 14px;
}

.interstitial-ad-slot.ad-live {
  background: transparent;
  border-style: solid;
  padding: 0;
}

.interstitial-ad-next {
  width: 100%;
  height: 48px;
  background: var(--white);
  color: #0e0e0e;
  border: none;
  border-radius: var(--radius-sm);
  font-family: "Noto Sans JP", sans-serif;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
}

.interstitial-ad-next:disabled {
  background: #333;
  color: #666;
  cursor: not-allowed;
}

/* ======================== */
/* ヘッダー                 */
/* ======================== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 10;
}

.header-back {
  min-width: 64px;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 9px;
  font-size: 11px;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.15s;
}

.header-back:hover,
.header-back:active {
  color: var(--text-sub);
  border-color: var(--border-hi);
  background: var(--bg-btn);
}

.app-name {
  font-family: "DM Mono", monospace;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 3px;
  color: var(--text);
}

.app-version {
  font-family: "DM Mono", monospace;
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 1px;
}

body.sim-page #settingScreen .page-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
}

body.sim-page #settingScreen .page-header .app-name {
  grid-column: 2;
}

body.sim-page #settingScreen .page-header .app-version {
  grid-column: 3;
  justify-self: end;
}

/* ======================== */
/* 設定コンテンツ           */
/* ======================== */
.setting-content {
  padding: 16px 14px 104px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 600px;
  margin: 0 auto;
}

/* ======================== */
/* カード                   */
/* ======================== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 18px;
  border: 1px solid var(--border);
}

.card-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-dim);
  text-transform: uppercase;
  margin-bottom: 16px;
}

.card-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.card-title-row .card-title {
  margin-bottom: 0;
}

/* ======================== */
/* 設定行                   */
/* ======================== */
.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.row:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.row-label {
  font-size: 13px;
  color: var(--text-sub);
  min-width: 0;
}

.row > .setting-slider {
  grid-column: 1 / -1;
}

/* ======================== */
/* ステッパー               */
/* ======================== */
.stepper {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

.step-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-btn);
  border: 1px solid var(--border-hi);
  color: var(--text-sub);
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.12s;
  flex-shrink: 0;
  font-family: "Noto Sans JP", sans-serif;
}

.step-btn:hover,
.step-btn:active {
  background: var(--border-hi);
  color: var(--text);
  transform: scale(1.08);
}

.step-val {
  display: flex;
  align-items: center;
  gap: 2px;
}

input[type="number"] {
  width: 70px;
  height: 34px;
  background: var(--bg-input);
  border: 1px solid var(--border-hi);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: "DM Mono", monospace;
  font-size: 14px;
  font-weight: 500;
  text-align: center;
  outline: none;
  -moz-appearance: textfield;
}

input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
}

input[type="number"]:focus {
  border-color: #555;
}

.val-prefix {
  font-family: "DM Mono", monospace;
  font-size: 12px;
  color: var(--text-dim);
}

.val-suffix {
  font-family: "DM Mono", monospace;
  font-size: 11px;
  color: var(--text-dim);
}

/* ======================== */
/* 割合バー                 */
/* ======================== */
.ratio-bar {
  display: flex;
  justify-content: space-between;
  font-family: "DM Mono", monospace;
  font-size: 11px;
  padding: 7px 10px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  color: var(--text-dim);
}

.ratio-bar .ok   { color: var(--green); }
.ratio-bar .over { color: var(--red); }

/* ======================== */
/* 出玉アイテム             */
/* ======================== */
.payout-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.payout-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.payout-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.payout-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  color: var(--text-dim);
  text-transform: uppercase;
  flex: 1;
}

.payout-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.payout-controls .stepper {
  width: 100%;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) 32px;
  gap: 8px;
}

.payout-controls .step-val {
  flex: 1;
  justify-content: center;
}

.setting-slider {
  width: 100%;
  height: 5px;
  border-radius: 999px;
  background: var(--border);
  appearance: none;
  outline: none;
  cursor: pointer;
}

.setting-slider::-webkit-slider-thumb {
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text-sub);
  border: 2px solid var(--bg-card);
}

.setting-slider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--text-sub);
  border: 2px solid var(--bg-card);
}

@media (min-width: 760px) {
  .setting-content {
    max-width: 680px;
  }
}

@media (max-width: 420px) {
  .card {
    padding: 15px;
  }

  .row {
    grid-template-columns: 1fr;
  }

  .row .stepper {
    justify-self: stretch;
    width: 100%;
    justify-content: space-between;
  }

  input[type="number"] {
    width: 76px;
  }
}

/* ======================== */
/* トグル                   */
/* ======================== */
.tog {
  position: relative;
  display: inline-flex;
  cursor: pointer;
  flex-shrink: 0;
}

.tog input[type="checkbox"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.tog-track {
  width: 38px;
  height: 22px;
  background: var(--bg-btn);
  border: 1px solid var(--border-hi);
  border-radius: 11px;
  position: relative;
  transition: all 0.2s;
  display: block;
}

.tog-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: all 0.2s;
}

.tog input:checked + .tog-track {
  background: #1e5c2a;
  border-color: var(--green);
}

.tog input:checked + .tog-track::after {
  left: 19px;
  background: var(--green);
}

.setting-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ======================== */
/* スタートボタン           */
/* ======================== */
.start-btn {
  width: 100%;
  height: 56px;
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-md);
  font-family: "Noto Sans JP", sans-serif;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.15s;
  margin-top: 4px;
}

.start-btn:hover,
.start-btn:active {
  background: #ccc;
  transform: translateY(-1px);
}

.setting-back-btn {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  background: #111;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  transition: all 0.15s;
}

.setting-back-btn:hover,
.setting-back-btn:active {
  color: var(--text-sub);
  border-color: var(--border-hi);
  background: var(--bg-btn);
}

.start-message {
  min-height: 20px;
  margin-top: 10px;
  color: var(--red);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.6;
  text-align: center;
}

.start-message:empty {
  display: none;
}

/* ======================== */
/* プレイ画面               */
/* ======================== */
.spin-display {
  font-family: "DM Mono", monospace;
  font-size: 56px;
  font-weight: 500;
  color: var(--text);
  text-align: center;
  padding: 28px 20px 10px;
  letter-spacing: -1px;
  transition: color 0.3s;
}

.spin-display.warning {
  color: var(--red);
  animation: warnPulse 0.7s ease-in-out infinite;
}

@keyframes warnPulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.5; }
}

.spin-unit {
  font-size: 18px;
  color: var(--text-dim);
  margin-left: 4px;
}

/* モードタグ */
.mode-tag {
  display: block;
  width: fit-content;
  margin: 0 auto 16px;
  font-family: "DM Mono", monospace;
  font-size: 11px;
  letter-spacing: 3px;
  padding: 5px 14px;
  border-radius: 20px;
  transition: all 0.3s;
}

.mode-normal {
  background: var(--bg-card);
  color: var(--text-dim);
  border: 1px solid var(--border);
}

.mode-rush {
  background: #1a0e00;
  color: var(--orange);
  border: 1px solid #3a2000;
}

.mode-lt {
  background: #001a1a;
  color: #00e5ff;
  border: 1px solid #003a3a;
}

/* ステータスグリッド */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  background: var(--border);
  margin: 0 14px 14px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
}

.stat-cell {
  background: var(--bg);
  padding: 14px;
}

.stat-lbl {
  font-size: 10px;
  color: var(--text-dim);
  letter-spacing: 1px;
  margin-bottom: 5px;
}

.stat-val {
  font-family: "DM Mono", monospace;
  font-size: 22px;
  font-weight: 500;
  color: var(--text);
  transition: color 0.2s;
}

.stat-val.val-up  { color: var(--green); }
.stat-val.val-dn  { color: var(--red); }
.stat-val.val-hi  { color: var(--orange); }
.stat-val.val-dim { color: var(--text-dim); }

.stat-u {
  font-size: 11px;
  color: var(--text-dim);
  margin-left: 2px;
}

/* ログ */
.log-box {
  margin: 0 14px 14px;
  background: var(--bg-input);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  min-height: 140px;
  max-height: 240px;
  overflow-y: auto;
  border: 1px solid var(--border);
}

.log-box::-webkit-scrollbar { width: 3px; }
.log-box::-webkit-scrollbar-track { background: transparent; }
.log-box::-webkit-scrollbar-thumb { background: var(--border-hi); border-radius: 2px; }

#log div {
  font-size: 13px;
  padding: 2px 0;
  line-height: 1.8;
}

.log-normal  { color: var(--text-dim); }
.log-hit     { color: var(--orange); }
.log-rush    { color: var(--orange); font-weight: 700; }
.log-lt      { color: #00e5ff; font-weight: 700; }
.log-payout  { color: var(--green); }
.log-fail    { color: var(--red); }
.log-end     { color: var(--text-dim); }
.log-hama    { color: var(--text-dim); opacity: 0.6; }

/* アクションエリア */
.action-area {
  padding: 0 14px 32px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.retry-btn {
  width: 100%;
  height: 52px;
  background: var(--text);
  color: var(--bg);
  border: none;
  border-radius: var(--radius-md);
  font-family: "Noto Sans JP", sans-serif;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
}

.retry-btn:hover, .retry-btn:active {
  background: #ccc;
}

.back-btn {
  width: 100%;
  height: 46px;
  background: transparent;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-family: "Noto Sans JP", sans-serif;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.back-btn:hover, .back-btn:active {
  border-color: var(--border-hi);
  color: var(--text-sub);
}

/* 演出 */
.payout-fx {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  font-family: "DM Mono", monospace;
  font-size: 52px;
  font-weight: 500;
  color: var(--green);
  pointer-events: none;
  z-index: 999;
  white-space: nowrap;
}

.payout-fx.show {
  animation: fxPop 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes fxPop {
  0%   { transform: translate(-50%,-50%) scale(0);    opacity: 0; }
  50%  { transform: translate(-50%,-50%) scale(1.1);  opacity: 1; }
  100% { transform: translate(-50%,-50%) scale(0.95); opacity: 0; }
}

/* 爆連 */
.body-flash {
  animation: bodyFlash 0.35s ease;
}

@keyframes bodyFlash {
  0%   { background-color: #1a1a00; }
  100% { background-color: var(--bg); }
}
