:root {
  --bar: #2f6f73; --bar-dark: #245b5f; --ink: #22302e; --gold: #e2a632; --kaki: #d2672e; --cream: #fbf5e8; --paper: #fffcf5;
  --round: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", sans-serif;
  --pop: "Mochiy Pop One", "Hiragino Maru Gothic ProN", sans-serif;
  --num: "Dela Gothic One", "Hiragino Sans", sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; background: var(--cream); }
body {
  color: var(--ink); font-family: var(--round); font-weight: 800; overflow: hidden;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
[hidden] { display: none !important; }

.screen { position: fixed; inset: 0; display: flex; flex-direction: column; align-items: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }

.band { width: 100%; flex: none; display: flex; align-items: baseline; justify-content: space-between; gap: 16px;
  background: var(--bar); color: #fff; border-bottom: 6px solid var(--kaki); padding: 14px 28px; }
.band .logo { font-family: var(--pop); font-size: 30px; }
.band small { font-size: 18px; opacity: .92; }

/* ---------- 待機画面 ---------- */
.machine-wrap { flex: 1; min-height: 0; width: 100%; display: flex; align-items: center; justify-content: center; padding: 24px 0 8px; }
.machine { height: 100%; max-height: 560px; width: auto; overflow: visible; }
#handle { transform-box: fill-box; transform-origin: center; }
.lead { font-size: clamp(22px, 3.4vw, 32px); line-height: 1.45; text-align: center; margin: 8px 24px 20px; }
.spin { width: min(78vw, 560px); padding: 26px 0; border-radius: 999px; background: var(--kaki); color: #fff;
  font-family: var(--pop); font-size: clamp(30px, 5vw, 44px); letter-spacing: .06em;
  box-shadow: 0 10px 0 #9c4a1e, 0 16px 26px rgba(34, 48, 46, .25); transition: transform .08s, box-shadow .08s; }
.spin:active { transform: translateY(8px); box-shadow: 0 2px 0 #9c4a1e, 0 6px 12px rgba(34, 48, 46, .25); }
.spin:disabled { background: #b9b2a3; box-shadow: 0 10px 0 #8d877a; }
.left { margin: 22px 0 28px; font-size: 18px; color: #6b7471; }

/* ---------- カプセルの演出 ---------- */
.capsule { position: fixed; left: 0; top: 0; width: 84px; height: 84px; margin: -42px 0 0 -42px; z-index: 20; pointer-events: none; }
.capsule i { position: absolute; left: 0; width: 100%; height: 50%; border: 4px solid var(--ink); }
.capsule .top { top: 0; border-radius: 42px 42px 0 0; background: var(--cap, var(--kaki)); border-bottom-width: 2px; }
.capsule .top::after { content: ""; position: absolute; left: 18%; top: 22%; width: 26%; height: 26%; border-radius: 50%; background: rgba(255, 255, 255, .6); }
.capsule .bottom { bottom: 0; border-radius: 0 0 42px 42px; background: #fff; border-top-width: 2px; }
.flash { position: fixed; inset: 0; z-index: 30; pointer-events: none; background: radial-gradient(circle, #fff 0 40%, rgba(255, 255, 255, .85) 70%, rgba(255, 255, 255, 0)); }

/* ---------- 当選画面 ---------- */
#result { background: var(--cream); }
.win { flex: 1; min-height: 0; width: 100%; max-width: 1100px; display: flex; flex-direction: column; gap: 18px; padding: 22px 28px 12px; }
.win-text { display: flex; flex-direction: column; gap: 14px; }
.win-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; }
.atari { font-family: var(--pop); font-size: clamp(46px, 8vw, 76px); color: var(--kaki); line-height: 1; white-space: nowrap; animation: pop .5s cubic-bezier(.2, 1.6, .4, 1) both; }
.meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: clamp(16px, 2.3vw, 22px); }
.meta b { font-family: var(--num); font-weight: 400; font-size: clamp(26px, 4vw, 38px); color: var(--bar); line-height: 1; }
.win-item { background: var(--paper); border: 6px solid var(--gold); border-radius: 28px; padding: 18px 26px;
  display: flex; align-items: baseline; justify-content: center; flex-wrap: wrap; gap: 4px 18px; text-align: center;
  font-family: var(--pop); font-size: clamp(34px, 6vw, 60px); line-height: 1.2; animation: pop .5s .1s cubic-bezier(.2, 1.4, .4, 1) both; }
.win-item.long { font-size: clamp(26px, 4.4vw, 42px); }
.win-item small { font-family: var(--round); font-weight: 800; font-size: .52em; color: #5b6461; }
.win-shop { display: flex; align-items: center; justify-content: center; gap: 16px; font-size: clamp(28px, 4.6vw, 44px); line-height: 1.2; text-align: left; }
.badge { flex: none; display: grid; place-items: center; min-width: 1.9em; height: 1.45em; padding: 0 .25em; border-radius: .3em;
  background: var(--cap, var(--bar)); color: var(--cap-ink, #fff); font-family: var(--num); font-weight: 400; font-style: normal; font-size: 1em; }
.win-note { background: #fff3cf; border-left: 8px solid var(--gold); border-radius: 10px; padding: 10px 16px; font-size: clamp(18px, 2.6vw, 24px); line-height: 1.45; }
.win-how { font-size: clamp(19px, 2.8vw, 26px); line-height: 1.5; text-align: center; font-weight: 800; text-wrap: balance; }
.win-how b { color: var(--kaki); }
.win-map { flex: 1; min-height: 0; display: flex; flex-direction: column; align-items: center; gap: 8px; }
#rMap { flex: 1; min-height: 0; width: 100%; display: grid; place-items: center; }
#rMap svg { width: auto; height: auto; max-width: 100%; max-height: 100%; border: 6px solid #fff; border-radius: 22px; background: #fbf5e7;
  box-shadow: 0 3px 12px rgba(34, 48, 46, .16); }
.win-map figcaption { font-size: 16px; display: flex; align-items: center; gap: 6px; color: #4d5754; }
.key { display: inline-block; width: 18px; height: 18px; border-radius: 4px; border: 4px solid var(--kaki); }
.key.hit { background: var(--kaki); }
.key.hq { background: #fff; }
.area .ring { animation: ring 1.2s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
@keyframes ring { 50% { transform: scale(1.25); opacity: .35; } }
@keyframes pop { from { transform: scale(.4); opacity: 0; } }

.hold { position: relative; overflow: hidden; flex: none; margin: 4px 0 22px; padding: 14px 34px; border-radius: 999px;
  background: #e6ddca; color: #5b6461; font-size: 18px; }
.hold::before { content: ""; position: absolute; inset: 0; width: 0; background: var(--bar); opacity: .35; }
.hold.pressing::before { width: 100%; transition: width var(--hold, .8s) linear; }
.hold span { position: relative; }

@media (orientation: landscape) {
  .win { flex-direction: row; align-items: stretch; }
  .win-text { flex: 0 0 50%; justify-content: center; }
  .win-map { flex: 1; }
}

/* ---------- 管理画面 ---------- */
.admin { position: fixed; inset: 0; z-index: 40; overflow-y: auto; -webkit-overflow-scrolling: touch; background: #fff;
  padding: calc(env(safe-area-inset-top) + 18px) 24px 40px; font-weight: 500; -webkit-user-select: text; user-select: text; }
.admin-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.admin h2 { font-family: var(--pop); font-weight: 400; font-size: 26px; color: var(--bar); }
.admin h3 { margin: 26px 0 4px; font-size: 20px; font-weight: 800; border-left: 6px solid var(--gold); padding-left: 10px; }
.admin .hint { font-size: 14px; color: #5b6461; margin-bottom: 8px; }
.admin button { border-radius: 10px; background: #ece6d8; padding: 10px 18px; font-weight: 800; font-size: 16px; }
.sum { display: flex; flex-wrap: wrap; gap: 10px; }
.sum div { background: var(--cream); border-radius: 12px; padding: 10px 16px; font-size: 15px; }
.sum b { display: block; font-family: var(--num); font-weight: 400; font-size: 28px; color: var(--bar); }
.tbl { width: 100%; border-collapse: collapse; font-size: 15px; }
.tbl th { text-align: left; font-size: 13px; color: #5b6461; border-bottom: 2px solid #d9d2c3; padding: 6px 6px; }
.tbl td { border-bottom: 1px solid #ece6d8; padding: 6px; vertical-align: middle; }
.tbl tr.out td { color: #9aa19e; }
.tbl tr.undone td { text-decoration: line-through; color: #9aa19e; }
.tbl td.no { font-family: var(--num); font-weight: 400; color: var(--bar); white-space: nowrap; }
.tbl input { width: 100%; font: inherit; font-weight: 800; padding: 6px 8px; border: 2px solid #d9d2c3; border-radius: 8px; background: #fff; }
.tbl input:placeholder-shown { border-color: var(--kaki); }
.tbl small { display: block; color: var(--kaki); font-size: 12px; }
.qty { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.qty b { min-width: 2.4em; text-align: center; font-size: 18px; }
.admin .qty button { padding: 6px 14px; font-size: 18px; }
.admin button.undo { padding: 6px 12px; font-size: 14px; }
.tools { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 26px; }
.admin button.danger { background: #fbe3d6; color: #a2431a; }
.ver { margin-top: 18px; font-size: 12px; color: #9aa19e; }
