/* =========================================================
 * バーテンダーシミュレーター（bartender） スタイル
 * ========================================================= */
:root {
  --font-jp: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", Meiryo, sans-serif;
  --font-num: "SF Mono", "Roboto Mono", Menlo, Consolas, monospace;
  --c-text: #2b1a10;
  --c-dim: #7d6654;
  --c-accent: #d98a1c;
  --c-accent-deep: #a8590b;
  --c-gold: #ffcf7a;
  --c-gold-deep: #f09a1e;
  --c-panel: rgba(255, 250, 243, 0.97);
  --c-line: rgba(58, 34, 18, 0.16);
  --c-glass: rgba(30, 16, 8, 0.78);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--font-jp);
  color: var(--c-text);
  background: #140c08;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-text-size-adjust: 100%;
}

.hidden { display: none !important; }
button { font-family: var(--font-jp); }
button:focus-visible, a:focus-visible { outline: 3px solid #ffc978; outline-offset: 2px; }

/* ===== レイアウト =====
   共通ヘッダー(--sgh-top)とフッター広告(--ad-space)のぶんだけ内側に収める */
#app {
  position: fixed;
  left: 0;
  right: 0;
  top: var(--sgh-top, 0px);
  bottom: var(--ad-space, 0px);
  display: flex;
  flex-direction: column;
}

/* ===== 上部バー =====
   タイトルだけの帯は縦幅を圧迫するので隠す（スクリーンリーダー向けにだけ残す）。
   h1 と、共通ヘッダーのメニューが click() で押す元ボタンは DOM に残す */
#topbar {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}
#logo { margin: 0; font-size: 16px; }
.icon-btn { width: 32px; height: 32px; padding: 0; }

/* ===== ステージ ===== */
#stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #140c08;
}
#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: pointer;
}
#stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 46%, transparent 58%, rgba(10, 5, 2, 0.42) 100%);
  z-index: 1;
}

/* ===== 状況の表示 ===== */
#hud {
  position: absolute;
  top: 6px;
  left: calc(8px + env(safe-area-inset-left, 0px));
  right: calc(8px + env(safe-area-inset-right, 0px));
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  pointer-events: none;
}
#chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 6px;
  max-width: 100%;
  padding: 4px 8px;
  border-radius: 12px;
  background: #fff8ec;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
  border-top: 3px solid var(--c-accent);
  font-size: 13px;
  font-weight: 900;
  white-space: nowrap;
}
#chip-no { font-family: var(--font-num); font-size: 11px; color: var(--c-dim); }
#chip-name { color: #6b3a08; }
#chip-time, #chip-cover { padding: 2px 8px; border-radius: 7px; font-variant-numeric: tabular-nums; }
#chip-time { background: #ffe6bd; min-width: 4.6em; text-align: center; }
#chip-time.warn { background: #f3a03a; color: #3a1c02; }
@keyframes warn-blink { 50% { opacity: 0.6; } }
#chip-cover { background: #dcefd6; color: #1f5a2a; min-width: 5.4em; text-align: center; }
#gauges {
  display: flex;
  gap: 10px;
  width: min(380px, 100%);
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--c-glass);
  border: 1px solid rgba(255, 215, 160, 0.18);
}
.gauge { flex: 1; display: flex; align-items: center; gap: 6px; min-width: 0; color: #fff; font-size: 11.5px; font-weight: 800; }
.g-label { flex: none; white-space: nowrap; color: rgba(255, 240, 220, 0.92); }
.g-bar { position: relative; flex: 1; height: 9px; border-radius: 999px; background: rgba(255, 255, 255, 0.16); overflow: hidden; }
.g-fill {
  position: absolute;
  inset: 0;
  transform-origin: 0 50%;
  transform: scaleX(0);
  border-radius: 999px;
  background: linear-gradient(90deg, #fff0cf, var(--c-gold) 55%, var(--c-gold-deep));
  transition: transform 0.12s linear;
}
.g-fill.stock { background: linear-gradient(90deg, #fff6cf, #ffe58a); }
#instr {
  margin: 0;
  max-width: min(560px, 100%);
  padding: 5px 12px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.45;
  text-align: center;
  color: #fff;
  background: rgba(30, 16, 8, 0.66);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6);
}
#instr:empty { display: none; }

/* ===== 操作 ===== */
#controls {
  position: absolute;
  left: calc(8px + env(safe-area-inset-left, 0px));
  right: calc(8px + env(safe-area-inset-right, 0px));
  bottom: 8px;
  z-index: 12;
  display: flex;
  justify-content: center;
  pointer-events: none;
}
#ctl { display: flex; width: min(320px, 100%); pointer-events: auto; }
#ctl .btn { flex: 1; min-height: 48px; font-size: 17px; }

#banner {
  position: absolute;
  left: 50%;
  top: 40%;
  z-index: 13;
  transform: translate(-50%, -50%);
  max-width: 94%;
  font-size: clamp(22px, 6vw, 38px);
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #fff;
  text-align: center;
  white-space: nowrap;
  text-shadow: 0 3px 0 rgba(120, 60, 0, 0.9), 0 6px 18px rgba(0, 0, 0, 0.7);
  pointer-events: none;
  opacity: 0;
}
#banner.show { animation: banner-pop 1.6s ease-out forwards; }
@keyframes banner-pop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  12% { opacity: 1; transform: translate(-50%, -50%) scale(1.08); }
  22% { transform: translate(-50%, -50%) scale(1); }
  75% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(1); }
}
@media (prefers-reduced-motion: reduce) { #banner.show { animation-duration: 1.6s; } #chip-time.warn { animation: none; } }

/* ===== 画面オーバーレイ共通 ===== */
.screen {
  position: absolute;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
#screen-loading { background: #140c08; }
.loading-panel { text-align: center; color: #ffeeda; font-size: 14px; }
.loading-pan {
  width: 54px;
  height: 54px;
  margin: 0 auto 12px;
  border-radius: 50%;
  border: 5px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--c-gold);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== タイトル ===== */
#screen-title { align-items: flex-end; background: linear-gradient(180deg, rgba(16, 8, 4, 0) 30%, rgba(16, 8, 4, 0.88) 76%); }
.title-panel { width: min(460px, 100%); text-align: center; color: #fff; }
.title-en { margin: 0; font-size: 12px; font-weight: 900; letter-spacing: 0.42em; color: #ffd9a0; }
.title-ja { margin: 2px 0 6px; line-height: 1.05; text-shadow: 0 3px 0 #5e2c05, 0 8px 22px rgba(0, 0, 0, 0.7); }
.title-ja .t1 { display: inline-block; font-size: clamp(38px, 11.5vw, 58px); font-weight: 900; letter-spacing: 0.03em; color: #fff6e6; }
.title-ja .t2 { display: inline-block; margin-left: 0.12em; font-size: clamp(38px, 11.5vw, 58px); font-weight: 900; color: var(--c-gold); }
.title-catch { margin: 0 0 6px; font-size: 15px; font-weight: 900; color: #ffe9c8; }
.title-desc { margin: 0 auto 8px; max-width: 400px; font-size: 12.5px; font-weight: 700; line-height: 1.6; color: rgba(255, 238, 214, 0.90); }
#title-best { margin: 0 0 10px; min-height: 1.3em; font-size: 13px; font-weight: 900; color: var(--c-gold); }
.title-buttons { display: flex; flex-direction: column; gap: 8px; }
.title-sub-buttons { display: flex; gap: 8px; }
.title-sub-buttons .btn { flex: 1; }

/* ===== ボタン ===== */
.btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 14px;
  padding: 12px 18px;
  font-family: var(--font-jp);
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  line-height: 1.25;
}
.btn small { font-size: 11px; font-weight: 700; opacity: 0.88; }
.btn:active { transform: scale(0.97); }
.btn-primary {
  color: #3a1c02;
  font-size: 19px;
  background: linear-gradient(135deg, #ffe0a0, #f09a1e);
  box-shadow: 0 6px 18px rgba(240, 150, 30, 0.42), inset 0 1px 0 rgba(255, 255, 255, 0.5);
}
.btn-primary:hover { filter: brightness(1.06); }
.btn-sub { color: #fff3e0; font-size: 14px; padding: 10px 12px; background: rgba(255, 255, 255, 0.1); border: 1px solid rgba(255, 220, 170, 0.28); }
.btn-sub:hover { background: rgba(255, 255, 255, 0.16); }

/* ===== 次のコップ ===== */
#screen-intro { align-items: flex-end; background: linear-gradient(180deg, rgba(16, 8, 4, 0) 40%, rgba(16, 8, 4, 0.5)); }
.intro-panel, .result-panel, .final-panel {
  width: min(440px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 14px 16px;
  border-radius: 18px;
  background: var(--c-panel);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.55);
}
.intro-no { margin: 0 0 8px; font-size: 12px; font-weight: 900; letter-spacing: 0.2em; color: var(--c-accent-deep); text-align: center; }
.intro-head { display: flex; align-items: center; gap: 12px; }
.intro-emoji { flex: none; width: 64px; height: 64px; border-radius: 50%; background: #ffe9c8; font-size: 40px; line-height: 64px; text-align: center; box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.07); }
.intro-main { min-width: 0; }
.intro-name { margin: 0 0 2px; font-size: 22px; font-weight: 900; }
.intro-limit { margin: 0; font-size: 13px; font-weight: 800; color: var(--c-dim); }
.intro-limit b { font-size: 17px; color: var(--c-accent-deep); }
.intro-limit small { display: block; font-size: 11px; font-weight: 700; }
.intro-desc { margin: 10px 0 12px; padding: 8px 12px; border-radius: 12px; font-size: 13.5px; font-weight: 800; line-height: 1.6; color: #6b3a08; background: rgba(255, 200, 120, 0.26); }
.intro-panel > .btn { width: 100%; }

/* ===== 結果 ===== */
#screen-result { align-items: flex-end; background: linear-gradient(180deg, rgba(16, 8, 4, 0) 34%, rgba(16, 8, 4, 0.5)); pointer-events: none; }
#screen-result .result-panel { pointer-events: auto; padding: 10px 14px; }
#screen-final { background: rgba(16, 8, 4, 0.74); }
.result-top { display: flex; align-items: center; justify-content: center; gap: 14px; }
.result-rank {
  flex: none;
  width: 58px;
  height: 58px;
  margin: 0;
  border-radius: 50%;
  font-size: 34px;
  font-weight: 900;
  line-height: 58px;
  text-align: center;
  color: #fff;
  background: linear-gradient(135deg, #f7c444, #e2802a);
  box-shadow: 0 4px 12px rgba(226, 128, 42, 0.45);
}
.result-rank.rank-S { background: linear-gradient(135deg, #ffe27a, #ff9a1c); text-shadow: 0 2px 0 rgba(150, 70, 0, 0.6); }
.result-rank.rank-B { background: linear-gradient(135deg, #8cc7ff, #3d7be0); box-shadow: none; }
.result-rank.rank-C, .result-rank.rank-D { background: linear-gradient(135deg, #b9aea4, #7d7067); box-shadow: none; }
.result-title { margin: 0; font-size: 14px; font-weight: 900; }
.result-score-row { margin: 0; line-height: 1.1; }
#result-score, #final-score { font-family: var(--font-num); font-size: 40px; font-weight: 900; color: var(--c-accent-deep); font-variant-numeric: tabular-nums; }
.result-unit { margin-left: 4px; font-size: 14px; font-weight: 900; color: var(--c-dim); }
.result-speech { margin: 6px 0; padding: 7px 10px; border-radius: 12px; background: #fff; border: 1px solid var(--c-line); font-size: 13px; font-weight: 800; line-height: 1.5; }
#result-rows, #final-rows { margin: 0 0 8px; padding: 0; list-style: none; }
#result-rows li { display: grid; grid-template-columns: 5.4em 1fr auto; align-items: baseline; gap: 6px; padding: 3px 2px; border-bottom: 1px dashed var(--c-line); font-size: 12.5px; font-weight: 800; }
#result-rows .r-name { font-weight: 900; }
#result-rows .r-note { color: var(--c-dim); font-size: 12px; min-width: 0; }
#result-rows .r-pt { font-family: var(--font-num); font-weight: 900; color: var(--c-accent-deep); white-space: nowrap; }
.result-buttons, .final-buttons, .modal-buttons { display: flex; gap: 8px; }
.result-buttons .btn, .final-buttons .btn, .modal-buttons .btn { flex: 1; }
.result-buttons .btn-primary { flex: 1.5; font-size: 17px; }
.result-panel .btn-sub, .final-panel .btn-sub, .modal-buttons .btn-sub { color: var(--c-text); background: rgba(58, 34, 18, 0.07); border-color: var(--c-line); }
#share-msg, #final-msg { margin: 6px 0 0; min-height: 1.2em; font-size: 12px; font-weight: 800; text-align: center; color: var(--c-dim); }
#share-msg:empty { display: none; }
.final-eyebrow { margin: 0 0 6px; font-size: 12px; font-weight: 900; letter-spacing: 0.3em; color: var(--c-accent-deep); text-align: center; }
#final-new { margin: 6px 0 0; font-size: 14px; font-weight: 900; text-align: center; color: #c9780c; }
#final-rows { margin-top: 10px; border-top: 2px dashed var(--c-line); }
#final-rows li { display: flex; align-items: center; gap: 8px; padding: 5px 2px; border-bottom: 1px dashed var(--c-line); font-size: 13px; font-weight: 800; }
#final-rows .f-face { font-size: 20px; }
#final-rows .f-name { flex: 1; min-width: 0; }
#final-rows .f-sub { display: block; font-size: 11.5px; color: var(--c-dim); }
#final-rows .f-pt { font-family: var(--font-num); font-size: 16px; font-weight: 900; color: var(--c-accent-deep); }
.final-buttons { flex-wrap: wrap; }
.final-buttons .btn-primary { flex: 1 1 100%; }

/* ===== 一時停止・エラー ===== */
#screen-paused, #gl-error { background: rgba(16, 8, 4, 0.74); cursor: pointer; }
.paused-panel { text-align: center; color: #fff; }
.paused-title { margin: 0 0 6px; font-size: 24px; font-weight: 900; }
.paused-hint { margin: 0; font-size: 13px; font-weight: 700; color: rgba(255, 238, 214, 0.8); }

/* ===== モーダル。広告より上に出すため body 直下に置く ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 2147482800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  padding-top: calc(16px + var(--sgh-top, 0px));
  padding-bottom: calc(16px + var(--ad-space, 0px));
  background: rgba(12, 6, 3, 0.68);
}
.modal-box {
  width: min(500px, 100%);
  max-height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 18px 18px 16px;
  border-radius: 16px;
  background: var(--c-panel);
  color: var(--c-text);
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.5);
  -webkit-user-select: text;
  user-select: text;
}
.modal-title { margin: 0 0 10px; font-size: 19px; text-align: center; }
.howto { margin: 0 0 14px; padding-left: 1.4em; font-size: 13.5px; line-height: 1.7; }
.howto li { margin-bottom: 6px; }
.howto b { color: var(--c-accent-deep); }
.modal-box > .btn { width: 100%; }
.confirm-box { width: min(400px, 100%); }
.confirm-text { margin: 4px 0 12px; font-size: 15px; font-weight: 800; line-height: 1.6; text-align: center; white-space: pre-line; }

/* ===== フッター ===== */
#footer {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 6px;
  text-align: center;
  font-size: 11px;
  line-height: 1.6;
  color: rgba(255, 238, 214, 0.7);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  pointer-events: none;
  z-index: 40;
  display: none;
}
#footer a { color: var(--c-gold); pointer-events: auto; }
body.on-title #footer { display: block; }
body.on-title #screen-title { padding-bottom: 48px; }

/* ===== 小さい画面・横向き ===== */
@media (max-height: 560px) {
  #hud { top: 3px; gap: 3px; }
  #instr { font-size: 12px; padding: 3px 10px; }
  #gauges { padding: 3px 10px; }
  .title-ja .t1, .title-ja .t2 { font-size: 32px; }
  .title-desc { display: none; }
  #ctl .btn { min-height: 38px; font-size: 15px; }
  .intro-emoji { width: 46px; height: 46px; font-size: 28px; line-height: 46px; }
}
@media (max-width: 380px) {
  #chips { font-size: 12px; gap: 3px 4px; }
  #instr { font-size: 12px; padding: 3px 10px; }
  .result-buttons .btn-primary { font-size: 15px; }
}
@media (max-height: 700px) {
  #result-score { font-size: 30px; }
  .result-rank { width: 44px; height: 44px; font-size: 26px; line-height: 44px; }
}
@media (max-height: 560px) and (min-width: 640px) {
  /* 横向きスマホ: 表示を左右に寄せる */
  #hud { align-items: flex-start; right: auto; max-width: 46%; }
  #controls { left: auto; width: 230px; }
  #screen-result { align-items: center; justify-content: flex-end; padding: 6px; }
  #screen-result .result-panel { width: 320px; padding: 6px 10px; }
  .result-speech { margin: 3px 0; padding: 4px 8px; font-size: 12px; }
  #result-rows { margin-bottom: 4px; }
  #result-rows li { font-size: 11.5px; padding: 1px 2px; }
  .result-buttons .btn { padding: 6px 4px; min-height: 0; font-size: 13px; }
  .result-buttons .btn-primary { font-size: 14px; }
  #screen-title { align-items: center; justify-content: flex-end; background: linear-gradient(90deg, rgba(16, 8, 4, 0) 34%, rgba(16, 8, 4, 0.90) 76%); }
  .title-panel { width: 320px; }
}

/* ===== レシピと進み具合 ===== */
#hud { gap: 4px; }
#readout {
  margin: 0;
  padding: 3px 14px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 900;
  color: #fff;
  background: var(--c-glass);
  border: 1px solid rgba(255, 215, 160, 0.2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
#readout:empty { display: none; }
#recipe {
  position: absolute;
  left: calc(6px + env(safe-area-inset-left, 0px));
  top: 82px;
  z-index: 9;
  width: min(43vw, 184px);
  padding: 6px 8px 5px;
  border-radius: 12px;
  background: rgba(24, 13, 7, 0.74);
  border: 1px solid rgba(255, 215, 160, 0.18);
  color: #fff3e0;
  font-size: 11px;
  font-weight: 800;
  pointer-events: none;
}
#recipe-title { margin: 0 0 2px; font-size: 9.5px; letter-spacing: 0.22em; color: var(--c-gold); }
#recipe-rows { margin: 0; padding: 0; list-style: none; }
#recipe-rows li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1px 6px; align-items: baseline; padding: 2px 0; line-height: 1.25; }
.rc-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rc-val { font-variant-numeric: tabular-nums; white-space: nowrap; color: rgba(255, 240, 220, 0.86); }
.rc-bar { position: relative; grid-column: 1 / -1; height: 4px; border-radius: 3px; background: rgba(255, 255, 255, 0.15); }
.rc-fill { position: absolute; inset: 0; border-radius: 3px; transform-origin: 0 50%; background: var(--c-gold); }
.rc-mark { position: absolute; left: 80%; top: -2px; bottom: -2px; width: 2px; margin-left: -1px; background: #fff; border-radius: 1px; }
#recipe-rows li.ok .rc-val { color: #a5f29b; }
#recipe-rows li.ok .rc-fill { background: #6fd66b; }
#recipe-rows li.over .rc-val { color: #ff9a85; }
#recipe-rows li.over .rc-fill { background: #ff6a4d; }
#recipe-rows li.cur .rc-name { color: var(--c-gold); }
#recipe-rows li.cur .rc-name::before { content: "▶ "; font-size: 9px; }
#recipe-rows li.sum { margin-top: 2px; border-top: 1px dashed rgba(255, 215, 160, 0.3); }

/* ===== 操作（ヒント・棚・道具） ===== */
#ctl {
  flex-direction: column;
  gap: 6px;
  width: min(560px, 100%);
  padding: 7px 8px 8px;
  border-radius: 16px;
  background: var(--c-glass);
  border: 1px solid rgba(255, 215, 160, 0.18);
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.45);
}
#ctl #instr {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.5em;
  max-width: none;
  margin: 0;
  padding: 0 4px;
  font-size: 12.5px;
  line-height: 1.25;
  background: none;
}
#shelf {
  position: relative;
  display: flex;
  gap: 6px;
  padding: 3px 2px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  touch-action: pan-x;
}
#shelf::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  width: 68px;
  min-height: 62px;
  padding: 7px 2px 5px;
  border-radius: 12px;
  border: 1.5px solid rgba(255, 220, 170, 0.24);
  background: rgba(255, 255, 255, 0.08);
  color: #fff3e0;
  font-family: var(--font-jp);
  font-size: 10.5px;
  font-weight: 800;
  line-height: 1.2;
  cursor: pointer;
}
.chip:hover { background: rgba(255, 255, 255, 0.14); }
.chip:active { transform: scale(0.95); }
.chip-dot {
  position: relative;
  flex: none;
  width: 14px;
  height: 20px;
  margin-top: 7px;
  border-radius: 3px 3px 4px 4px;
  background: #ddd;
  box-shadow: inset -3px 0 0 rgba(0, 0, 0, 0.18), inset 2px 0 0 rgba(255, 255, 255, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.25);
}
.chip-dot::before {
  content: "";
  position: absolute;
  left: 4px;
  top: -7px;
  width: 6px;
  height: 7px;
  border-radius: 2px 2px 0 0;
  background: inherit;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.25);
}
.chip-soda .chip-dot, .chip-small .chip-dot { width: 12px; }
.chip-soda .chip-dot::before, .chip-small .chip-dot::before { left: 3px; }
.chip-juice .chip-dot { width: 16px; border-radius: 4px; }
.chip-juice .chip-dot::before { left: 4px; width: 8px; }
.chip-garn .chip-dot { width: 24px; height: 24px; margin-top: 3px; border-radius: 50%; box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.35), inset 0 0 0 5px rgba(0, 0, 0, 0.08); }
.chip-garn .chip-dot::before { display: none; }
.chip-ice .chip-dot {
  width: 24px;
  height: 24px;
  margin-top: 2px;
  border-radius: 5px;
  background: linear-gradient(135deg, #f4fbff 0%, #bfe4f7 55%, #8cc6e8 100%);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.75), inset -4px -4px 0 rgba(60, 130, 180, 0.22);
}
.chip-ice .chip-dot::before { display: none; }
.chip.chip-ice { width: 54px; }
.chip-ice-rock .chip-dot { border-radius: 0; box-shadow: none; -webkit-clip-path: polygon(22% 4%, 70% 0, 100% 34%, 88% 86%, 46% 100%, 4% 72%, 0 30%); clip-path: polygon(22% 4%, 70% 0, 100% 34%, 88% 86%, 46% 100%, 4% 72%, 0 30%); background: linear-gradient(120deg, #ffffff 0%, #d6eefb 38%, #9fd0ee 60%, #e6f5fd 100%); }
.chip-ice-ball .chip-dot { border-radius: 50%; background: radial-gradient(circle at 34% 30%, #ffffff 0%, #d2ecfa 38%, #8cc6e8 100%); box-shadow: inset -3px -3px 0 rgba(60, 130, 180, 0.2); }
.chip-name { display: block; max-width: 100%; text-align: center; word-break: break-all; }
.chip.sel { border-color: var(--c-gold); background: rgba(255, 196, 100, 0.28); box-shadow: 0 0 0 2px rgba(255, 207, 122, 0.45); }
.chip.is-off, .btn-act.is-off { opacity: 0.36; }
#actions { display: flex; gap: 6px; }
#ctl .btn-act {
  flex: 1;
  min-height: 44px;
  padding: 8px 4px;
  border-radius: 12px;
  font-size: 13.5px;
  white-space: nowrap;
  color: #fff3e0;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 220, 170, 0.28);
}
#ctl .btn-act.sel { color: #3a1c02; background: linear-gradient(135deg, #ffe0a0, #f0a83a); border-color: transparent; }
#ctl .btn-redo { flex: none; width: 44px; font-size: 16px; }
#ctl #btn-serve { flex: 1.25; min-height: 44px; padding: 8px 6px; font-size: 15.5px; white-space: nowrap; }
#btn-serve.is-off { filter: grayscale(0.7) brightness(0.8); opacity: 0.7; }
#game-canvas { cursor: grab; }

/* ===== 注文・フリーの準備 ===== */
.btn-second {
  color: #fff3e0;
  font-size: 17px;
  background: linear-gradient(135deg, #8a5520, #4f2c0e);
  border: 1px solid rgba(255, 220, 170, 0.38);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.18);
}
.btn-second:hover { filter: brightness(1.1); }
.order-say { margin: 0 0 2px; font-size: 13px; font-weight: 800; line-height: 1.45; color: var(--c-dim); }
#screen-order .intro-name { font-size: 21px; }
#screen-order .intro-desc { margin: 8px 0; }
.order-steps { margin: 0 0 10px; padding-left: 1.6em; font-size: 12.5px; font-weight: 700; line-height: 1.6; }
.order-steps li::marker { font-weight: 900; color: var(--c-accent-deep); }
.free-title { margin: 0 0 6px; text-align: center; font-size: 20px; }
#screen-free { background: linear-gradient(180deg, rgba(16, 8, 4, 0) 20%, rgba(16, 8, 4, 0.55)); align-items: flex-end; }
.free-picks { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
.free-picks .btn { width: 100%; padding: 8px 6px; font-size: 14.5px; }
.free-picks .btn small { font-size: 10.5px; }
.free-pick-wide { grid-column: 1 / -1; }
#screen-free .intro-panel > .btn-sub { width: 100%; color: var(--c-text); background: rgba(58, 34, 18, 0.07); border-color: var(--c-line); }
.result-rank.rank-free { font-size: 30px; background: linear-gradient(135deg, #ffe7b5, #f0a83a); }
#result-rows li { grid-template-columns: 5.6em 1fr auto; }
.howto-note { margin: 0 0 12px; font-size: 11.5px; font-weight: 700; color: var(--c-dim); }
.title-ja .t1, .title-ja .t2 { font-size: clamp(27px, 8.2vw, 46px); }
.title-ja .t2 { margin-left: 0; }

/* ===== 「ここまで」の線の札 ===== */
#line-tag {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 5;
  margin-left: 6px;
  padding: 2px 7px 2px 9px;
  font-size: 11.5px;
  font-weight: 900;
  line-height: 1.5;
  color: #2b1a10;
  white-space: nowrap;
  background: #ffcf7a;
  border-radius: 3px 6px 6px 3px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
  pointer-events: none;
  will-change: transform;
}
#line-tag::before {
  content: "";
  position: absolute;
  right: 100%;
  top: 50%;
  margin-top: -6px;
  border: 6px solid transparent;
  border-right-color: #ffcf7a;
  border-left-width: 0;
}

@media (max-height: 620px) {
  .chip { min-height: 54px; padding-top: 4px; }
  #ctl { gap: 4px; padding: 5px 7px 6px; }
  #ctl .btn-act, #ctl #btn-serve { min-height: 38px; padding: 5px 4px; }
  #ctl #instr { min-height: 2.4em; font-size: 12px; }
  .order-steps { font-size: 12px; line-height: 1.5; }
}
@media (max-width: 619px) {
  #recipe { max-height: calc(100% - 290px); overflow: hidden; }
}
@media (min-width: 620px) {
  #recipe { width: 216px; font-size: 12px; top: 10px; }
  #ctl #instr { font-size: 13.5px; min-height: 1.8em; }
}
@media (max-height: 560px) and (min-width: 640px) {
  /* 横向きスマホ: 操作を右下に寄せる */
  #hud { align-items: center; right: calc(8px + env(safe-area-inset-right, 0px)); max-width: none; }
  #controls { left: auto; width: 330px; }
  #screen-order, #screen-free { align-items: center; justify-content: flex-end; }
  #screen-order .intro-panel, #screen-free .intro-panel { width: 340px; }
}

/* ===== 全国ランキング（共通モジュール sgr-*） ===== */
.sgr-overlay {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  padding-bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  background: rgba(6, 12, 18, 0.66);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.sgr-hidden { display: none !important; }

.sgr-panel {
  width: min(420px, 100%);
  max-height: min(80vh, 640px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--c-panel);
  color: var(--c-text);
  border-radius: 14px;
  padding: 20px 18px;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.45);
}

.sgr-title {
  margin: 0;
  font-size: 20px;
  text-align: center;
}

.sgr-tabs {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.sgr-tab {
  border: 1px solid var(--c-line);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: bold;
  font-family: var(--font-jp);
  background: rgba(226, 80, 42, 0.08);
  color: var(--c-text);
  cursor: pointer;
}

.sgr-tab-active {
  background: linear-gradient(135deg, var(--c-accent), var(--c-accent-deep));
  border-color: transparent;
  color: #fff;
}

.sgr-register-msg {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: bold;
  text-align: center;
  color: var(--c-orange);
}

.sgr-form { display: flex; gap: 8px; }

.sgr-name {
  flex: 1;
  min-width: 0;
  font-size: 16px; /* iOSズーム防止のため16px以上 */
  font-family: var(--font-jp);
  padding: 8px 10px;
  border: 2px solid var(--c-line);
  border-radius: 8px;
  background: #fff;
  color: var(--c-text);
  -webkit-user-select: text;
  user-select: text;
}

.sgr-name::placeholder { color: var(--c-dim); }

.sgr-name:focus {
  outline: none;
  border-color: var(--c-accent);
  box-shadow: 0 0 8px rgba(226, 80, 42, 0.3);
}

.sgr-submit {
  border: none;
  border-radius: 8px;
  padding: 8px 16px;
  font-size: 15px;
  font-weight: bold;
  font-family: var(--font-jp);
  background: linear-gradient(135deg, var(--c-accent), var(--c-accent-deep));
  color: #fff;
  cursor: pointer;
}

.sgr-submit:hover { filter: brightness(1.1); }

.sgr-submit:disabled { opacity: 0.5; cursor: default; }

.sgr-error {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--c-red);
}

.sgr-status {
  margin: 0;
  font-size: 13px;
  text-align: center;
  color: var(--c-dim);
}

.sgr-list {
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  flex: 1;
}

.sgr-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.sgr-row:nth-child(even) { background: rgba(226, 80, 42, 0.07); }

.sgr-row.sgr-row-me {
  background: linear-gradient(135deg, var(--c-accent), var(--c-accent-deep));
  color: #fff;
}

.sgr-rank {
  width: 2em;
  text-align: right;
  font-weight: bold;
  flex-shrink: 0;
}

.sgr-row-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sgr-row-score {
  font-weight: bold;
  font-family: var(--font-num);
  flex-shrink: 0;
}

.sgr-close {
  border: 1px solid var(--c-line);
  border-radius: 8px;
  padding: 10px;
  font-size: 14px;
  font-weight: bold;
  font-family: var(--font-jp);
  background: rgba(226, 80, 42, 0.08);
  color: var(--c-text);
  cursor: pointer;
}

.sgr-close:hover { border-color: var(--c-accent); }

.sgr-cta {
  margin: 2px 0 12px;
  text-align: center;
}

.sgr-cta-msg {
  margin: 0 0 6px;
  font-size: 14px;
  font-weight: bold;
  color: var(--c-orange);
}

.sgr-cta-btn {
  border: none;
  border-radius: 999px;
  padding: 10px 22px;
  font-size: 15px;
  font-weight: bold;
  font-family: var(--font-jp);
  background: linear-gradient(135deg, #f5a623, #f0741e);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(240, 116, 30, 0.4);
}

.sgr-cta-btn:hover { filter: brightness(1.08); }

.sgr-cta-link {
  border: none;
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 13px;
  font-weight: bold;
  font-family: var(--font-jp);
  background: rgba(30, 43, 56, 0.08);
  border: 1px solid var(--c-line);
  color: var(--c-text);
  cursor: pointer;
}

/* ==========================================================================
   フッター固定バナー広告（スマホ表示時のみ / js/ad-banner.js が挿入する）
   --ad-h    : 広告そのものの高さ。広告なしのときは 0px
   --ad-space: レイアウトが空けるべき高さ（広告 + セーフエリア）
   ========================================================================== */
:root {
  --ad-h: 0px;
  --ad-space: 0px;
}
html.has-ad-banner {
  --ad-space: calc(var(--ad-h, 0px) + env(safe-area-inset-bottom, 0px));
}

.ad-banner {
  /* height は広告そのものの高さ。セーフエリアぶんの padding は外側に足す */
  box-sizing: content-box;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  /* ランキング・リザルト等の全画面オーバーレイ（2147483000）よりは下に置く */
  z-index: 2147482000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  height: var(--ad-h, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  overflow: hidden;
  background: rgba(14, 16, 20, 0.86);
  /* border ではなく inset shadow にして、枠線ぶん高さがずれないようにする */
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.14);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.ad-banner__frame {
  display: block;
  width: 100%;
  height: var(--ad-h, 0px);
  border: 0;
  color-scheme: light;
}

@media print {
  .ad-banner { display: none; }
}
