/* 昭和10円ゲーム横丁 — 駄菓子屋の店先の筐体をイメージした画面 */
:root {
  --font: "BIZ UDPGothic", "BIZ UDPゴシック", sans-serif;
  --wall: #2a1a10;
  --wood: #6b4226;
  --wood-dark: #3d2414;
  --paper: #f4e9cf;
  --ink: #2b1d12;
  --lamp: #ffd25a;
  --red: #d8402c;
  --chrome-1: #f4f6f8;
  --chrome-2: #9aa3ab;
  --chrome-3: #5d666e;
  --focus: #ffe066;
  --cab: #1e7fa8;
  --accent: #e8432f;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100svh;
  font-family: var(--font);
  color: var(--paper);
  background-color: var(--wall);
  background-image:
    repeating-linear-gradient(90deg, rgba(0, 0, 0, 0.18) 0 2px, transparent 2px 86px),
    linear-gradient(180deg, #3a2414 0%, #24160c 60%, #1c1009 100%);
  line-height: 1.6;
}

button,
input,
select,
textarea {
  font-family: inherit;
  font-size: inherit;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* ---------- ヘッダー ---------- */
.site-head {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 12px;
  padding-top: max(6px, env(safe-area-inset-top));
  background: linear-gradient(180deg, #5b3820, #3d2414);
  border-bottom: 3px solid #1a0e06;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--paper);
  text-decoration: none;
  min-height: 44px;
}

.logo-coin {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f6c08c, #c77a3e 60%, #7a4012);
  color: #5a2a0a;
  font-weight: 700;
  font-size: 13px;
  box-shadow: inset 0 0 0 2px rgba(90, 40, 10, 0.5);
}

.logo-text {
  font-weight: 700;
  font-size: clamp(15px, 4.2vw, 20px);
  letter-spacing: 0.06em;
  text-shadow: 0 2px 0 #1a0e06;
}

.head-actions {
  display: flex;
  gap: 6px;
}

/* ---------- ボタン ---------- */
.btn {
  min-height: 44px;
  padding: 8px 16px;
  border-radius: 8px;
  border: 2px solid transparent;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.08s, filter 0.15s, background 0.15s;
}

.btn:hover {
  filter: brightness(1.1);
}

.btn:active {
  transform: translateY(1px);
}

.btn-head {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: #2a180c;
  color: var(--paper);
  border-color: #8a6a3a;
  font-size: 14px;
}

.mute-icon {
  width: 20px;
  height: 20px;
}

.btn-head .cross {
  display: none;
}

.btn-head.off .cross {
  display: inline;
}

.btn-head.off .wave {
  display: none;
}

.btn-head.off {
  color: #c9b28a;
}

.btn-primary {
  background: linear-gradient(180deg, #ffde6b, #f0b429);
  color: #3a2408;
  border-color: #a8740c;
}

.btn-ghost {
  background: #3a2414;
  color: var(--paper);
  border-color: #8a6a3a;
}

.btn-danger {
  background: linear-gradient(180deg, #f06a55, #c8392a);
  color: #fff;
  border-color: #7c1d12;
}

.btn-back {
  padding: 6px 12px;
  background: #3a2414;
  color: var(--paper);
  border-color: #8a6a3a;
  white-space: nowrap;
}

/* ---------- 一覧 ---------- */
main {
  max-width: 1180px;
  margin: 0 auto;
  padding: 12px 12px calc(24px + env(safe-area-inset-bottom));
  outline: none;
}

.list-intro {
  margin: 4px auto 16px;
  padding: 12px 16px;
  max-width: 720px;
  background: var(--paper);
  color: var(--ink);
  border-radius: 4px;
  box-shadow: 0 3px 0 #b8a37a, 0 6px 14px rgba(0, 0, 0, 0.4);
  transform: rotate(-0.4deg);
  text-align: center;
}

.list-intro p {
  margin: 2px 0;
}

.intro-lead {
  font-weight: 700;
  font-size: 1.15em;
  color: var(--red);
}

.cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr));
  gap: 14px;
}

@media (max-width: 520px) {
  .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
}

.card {
  display: flex;
  flex-direction: column;
  height: 100%;
  color: var(--ink);
  text-decoration: none;
  background: var(--paper);
  border-radius: 10px;
  border: 3px solid var(--wood-dark);
  box-shadow: 0 4px 0 #1a0e06, 0 10px 18px rgba(0, 0, 0, 0.45);
  overflow: hidden;
  transition: transform 0.15s, box-shadow 0.15s;
}

.card:hover,
.card:focus-visible {
  transform: translateY(-4px);
  box-shadow: 0 8px 0 #1a0e06, 0 16px 24px rgba(0, 0, 0, 0.5);
}

.card:active {
  transform: translateY(0);
}

.card-thumb {
  display: block;
  padding: 10px 18px 6px;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255, 210, 90, 0.35), transparent 70%),
    linear-gradient(180deg, #4a2c18, #2e1b0e);
}

.card-thumb svg {
  display: block;
  width: 100%;
  max-width: 150px;
  margin: 0 auto;
  height: auto;
}

.card-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px 12px;
  border-top: 4px solid var(--cab);
  flex: 1;
}

.card-no {
  font-size: 12px;
  color: #7a5a3a;
}

.card-name {
  font-weight: 700;
  font-size: 1.12em;
  line-height: 1.3;
}

.card-catch {
  font-size: 13px;
  line-height: 1.45;
  color: #4a3626;
}

.card-rec {
  margin-top: auto;
  padding-top: 6px;
  font-size: 12px;
  color: #6a4a2a;
}

.list-foot {
  margin-top: 20px;
  text-align: center;
  font-size: 13px;
  color: #c9b28a;
}

.notice {
  margin: 8px 0;
  padding: 8px 12px;
  border-radius: 6px;
  background: #fff1c2;
  color: #5a3a08;
  border: 2px solid #e0b030;
}

/* ---------- プレイ画面 ---------- */
.play-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.play-title h1 {
  margin: 0;
  font-size: clamp(18px, 5vw, 24px);
  line-height: 1.2;
}

.play-record {
  margin: 0;
  font-size: 13px;
  color: #e9d6aa;
}

.play-goal {
  margin: 4px 0 8px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--paper);
}

.goal-tag {
  display: inline-block;
  margin-right: 6px;
  padding: 0 6px;
  border-radius: 4px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  vertical-align: 1px;
}

.play-body {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-start;
  justify-content: center;
}

/* 筐体 */
.cabinet {
  --board-w: min(100%, var(--board-fit, 420px), 460px);
  flex: 0 1 auto;
  width: max(300px, min(100%, calc(var(--board-w) + 28px)));
  max-width: 100%;
  padding: 8px 10px 12px;
  border-radius: 12px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0) 18%, rgba(0, 0, 0, 0) 80%, rgba(0, 0, 0, 0.25)),
    var(--cab);
  border: 4px solid var(--wood-dark);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.15),
    inset 0 -6px 0 rgba(0, 0, 0, 0.2),
    0 12px 26px rgba(0, 0, 0, 0.55);
}

@media (max-width: 520px) {
  .cabinet {
    width: 100%;
  }
}

.cab-plate {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0 auto 6px;
  padding: 2px 10px;
  max-width: 92%;
  border-radius: 4px;
  background: linear-gradient(180deg, #f3e7c3, #d9c48f);
  border: 2px solid #8a6a3a;
  color: #3b2414;
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
}

.cab-no,
.cab-price {
  font-size: 11px;
  padding: 0 4px;
  border-radius: 3px;
  background: #3b2414;
  color: #f3e7c3;
}

.board-wrap {
  position: relative;
  width: var(--board-w);
  margin: 0 auto;
  aspect-ratio: 2 / 3;
  border-radius: 6px;
  padding: 0;
  background: #111;
  box-shadow:
    0 0 0 4px #c9ced3,
    0 0 0 6px #6b737a,
    inset 0 0 12px rgba(0, 0, 0, 0.8);
}

.board {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 4px;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 12px;
  pointer-events: none;
}

.overlay.show {
  display: flex;
}

.overlay.show:not(.hint) {
  background: rgba(20, 10, 4, 0.62);
  pointer-events: auto;
}

.overlay.hint {
  align-items: flex-end;
  padding-bottom: 14%;
}

.ov-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(20, 10, 4, 0.78);
  color: var(--lamp);
  font-weight: 700;
  font-size: 15px;
  border: 2px solid rgba(255, 210, 90, 0.6);
  text-align: center;
}

.ov-coin {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f6c08c, #c77a3e 60%, #7a4012);
  flex: none;
}

.ov-card {
  width: min(100%, 300px);
  padding: 14px 16px;
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  text-align: center;
  border: 3px solid var(--wood-dark);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.6);
}

.ov-card p {
  margin: 4px 0;
}

.ov-mark {
  font-size: 34px;
  line-height: 1;
  font-weight: 700;
}

.ov-win .ov-mark {
  color: #d8402c;
}

.ov-lose .ov-mark {
  color: #3b5a8a;
}

.ov-neutral .ov-mark {
  color: #6a4a2a;
}

.ov-title {
  font-weight: 700;
  font-size: 20px;
}

.ov-detail {
  font-size: 15px;
}

.ov-new {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 4px;
  background: #d8402c;
  color: #fff;
  font-weight: 700;
}

.ov-note {
  font-size: 13px;
  color: #6a4a2a;
}

.ov-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 10px;
}

.ov-actions .btn {
  flex: 1 1 110px;
}

/* 表示窓（得点・残り球・時間） */
.hud {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 8px 0 2px;
  min-height: 40px;
}

.hud-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 64px;
  padding: 2px 8px;
  border-radius: 5px;
  background: #160d07;
  border: 2px solid #8a6a3a;
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.8);
}

.hud-label {
  font-size: 10px;
  color: #c9b28a;
  line-height: 1.2;
}

.hud-value {
  font-size: 17px;
  font-weight: 700;
  color: #ffb84a;
  line-height: 1.2;
  text-shadow: 0 0 6px rgba(255, 150, 40, 0.6);
  font-variant-numeric: tabular-nums;
}

.msg {
  margin: 2px 0 6px;
  min-height: 1.5em;
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  color: #fff8e0;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

/* 操作部 */
.panel {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
  box-shadow: inset 0 2px 6px rgba(0, 0, 0, 0.35);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.ctl-col {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ctl-left:empty,
.ctl-right:empty {
  display: none;
}

.panel:has(.ctl-left:empty) {
  grid-template-columns: 1fr auto;
}

.panel:has(.ctl-left:empty):has(.ctl-right:empty) {
  grid-template-columns: 1fr;
}

.coin-row {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.btn-coin {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 6px 12px 6px 8px;
  border-radius: 8px;
  background: linear-gradient(180deg, #e6e9ec, #a9b1b8);
  border: 2px solid #5d666e;
  color: #222;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 3px 0 #3c4349;
}

.btn-coin:disabled {
  opacity: 0.55;
  cursor: default;
  box-shadow: 0 1px 0 #3c4349;
  transform: translateY(2px);
}

.coin-slot {
  position: relative;
  width: 10px;
  height: 30px;
  border-radius: 3px;
  background: #111;
  box-shadow: inset 0 0 0 2px #444;
  overflow: visible;
}

.coin-anim {
  position: absolute;
  left: 50%;
  top: -10px;
  width: 22px;
  height: 22px;
  margin-left: -11px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f6c08c, #c77a3e 60%, #7a4012);
  opacity: 0;
}

.btn-coin.dropping .coin-anim {
  animation: coin-drop 0.45s ease-in;
}

@keyframes coin-drop {
  0% {
    opacity: 1;
    transform: translateY(-14px) scaleX(1);
  }
  60% {
    opacity: 1;
    transform: translateY(4px) scaleX(0.35);
  }
  100% {
    opacity: 0;
    transform: translateY(12px) scaleX(0.2);
  }
}

.btn-start {
  min-width: 84px;
  min-height: 48px;
  padding: 6px 12px;
  border-radius: 8px;
  background: linear-gradient(180deg, #ff6b57, #c82a1c);
  border: 2px solid #6c140c;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.08em;
  cursor: pointer;
  box-shadow: 0 3px 0 #5a0f08;
}

.btn-start:disabled {
  opacity: 0.45;
  cursor: default;
  box-shadow: 0 1px 0 #5a0f08;
  transform: translateY(2px);
}

.blink {
  animation: lamp-blink 1.1s ease-in-out infinite;
}

@keyframes lamp-blink {
  50% {
    filter: brightness(1.25);
    box-shadow: 0 3px 0 #3c4349, 0 0 14px 3px rgba(255, 210, 90, 0.75);
  }
}

.ctl-center-extra {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.ctl-center-extra:empty {
  display: none;
}

/* ゲーム固有の操作ボタン（金属レバー風） */
.btn-ctl {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  min-height: 56px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 2px solid #3c4349;
  background: linear-gradient(180deg, var(--chrome-1), var(--chrome-2) 70%, var(--chrome-3));
  color: #1d2328;
  font-weight: 700;
  cursor: pointer;
  overflow: hidden;
  touch-action: none;
  box-shadow: 0 4px 0 #2b3136, inset 0 1px 0 #fff;
  transition: transform 0.05s, box-shadow 0.05s, filter 0.15s;
}

.btn-ctl:hover {
  filter: brightness(1.06);
}

.btn-ctl.pressed {
  transform: translateY(3px);
  box-shadow: 0 1px 0 #2b3136, inset 0 2px 4px rgba(0, 0, 0, 0.3);
}

.btn-ctl.active {
  border-color: var(--lamp);
  box-shadow: 0 4px 0 #2b3136, 0 0 0 3px rgba(255, 210, 90, 0.55), 0 0 14px rgba(255, 210, 90, 0.6);
}

.btn-ctl.dim {
  opacity: 0.5;
}

.btn-ctl.selected {
  background: linear-gradient(180deg, #ffe58a, #f0b429 70%, #b07a10);
  border-color: #6a4808;
}

.ctl-label {
  position: relative;
  z-index: 1;
  font-size: 15px;
  line-height: 1.2;
}

.ctl-sub {
  position: relative;
  z-index: 1;
  font-size: 10px;
  font-weight: 400;
  color: #39424a;
}

.ctl-gauge {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 100%;
  height: calc(var(--level, 0) * 100%);
  background: linear-gradient(0deg, rgba(232, 67, 47, 0.75), rgba(255, 210, 90, 0.6));
  pointer-events: none;
}

.ctl-lever {
  min-width: 78px;
  min-height: 84px;
}

.ctl-num {
  min-width: 46px;
  min-height: 46px;
  padding: 4px;
}

.ctl-num .ctl-label {
  font-size: 18px;
}

.ctl-wide {
  min-width: 140px;
}

/* 方向ボタン（十字） */
.panel[data-layout="dpad"] .ctl-center-extra {
  display: grid;
  grid-template-columns: repeat(3, 58px);
  grid-template-rows: repeat(2, 50px);
  grid-template-areas: ". up ." "left down right";
  justify-content: center;
  gap: 6px;
}

.ctl-dir-up {
  grid-area: up;
}

.ctl-dir-down {
  grid-area: down;
}

.ctl-dir-left {
  grid-area: left;
}

.ctl-dir-right {
  grid-area: right;
}

.panel[data-layout="dpad"] .btn-ctl {
  min-width: 0;
  min-height: 0;
}

/* 遊び方 */
.howto {
  flex: 1 1 280px;
  max-width: 460px;
  padding: 10px 14px;
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 3px 0 #b8a37a, 0 6px 14px rgba(0, 0, 0, 0.4);
}

.howto summary {
  min-height: 32px;
  font-weight: 700;
  cursor: pointer;
}

.howto ol {
  margin: 6px 0;
  padding-left: 1.4em;
}

.howto li {
  margin: 3px 0;
}

.howto-keys {
  margin: 6px 0 0;
  font-size: 14px;
}

.prob-table {
  width: 100%;
  margin-top: 8px;
  border-collapse: collapse;
  font-size: 14px;
}

.prob-table th,
.prob-table td {
  padding: 3px 6px;
  border: 1px solid #c9b28a;
  text-align: center;
}

/* モーダル・トースト */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(10, 5, 2, 0.7);
}

.modal {
  width: min(100%, 380px);
  max-height: 90svh;
  overflow: auto;
  padding: 18px;
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  border: 3px solid var(--wood-dark);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
}

.modal-wide {
  width: min(100%, 520px);
}

.modal-title {
  margin: 0 0 10px;
  font-size: 20px;
}

.modal-msg {
  margin: 0 0 14px;
  font-weight: 700;
}

.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 14px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px dashed #c9b28a;
}

.table-scroll {
  overflow-x: auto;
}

.rec-table {
  width: 100%;
  margin-top: 10px;
  border-collapse: collapse;
  font-size: 14px;
}

.rec-table th,
.rec-table td {
  padding: 5px 6px;
  border-bottom: 1px solid #d8c69a;
  text-align: left;
}

.rec-table thead th {
  font-size: 12px;
  color: #6a4a2a;
}

.toast-wrap {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  padding: 10px 18px;
  border-radius: 999px;
  background: #2a180c;
  color: var(--paper);
  border: 2px solid var(--lamp);
  font-weight: 700;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.5);
  transition: opacity 0.3s;
}

.toast.out {
  opacity: 0;
}

@media (max-width: 520px) {
  main {
    padding: 8px 8px calc(16px + env(safe-area-inset-bottom));
  }
  .play-goal {
    font-size: 13px;
    margin: 2px 0 6px;
  }
  .hud {
    margin-top: 6px;
    min-height: 36px;
  }
  .hud-item {
    min-width: 56px;
  }
  .msg {
    font-size: 13px;
    margin-bottom: 4px;
  }
  .coin-label {
    font-size: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------- スマートフォン縦持ち：盤面と操作部を同時に見せる ---------- */
@media (max-width: 520px) {
  .site-head {
    position: static;
    padding: 4px 8px;
  }
  .logo {
    min-height: 40px;
    gap: 6px;
  }
  .logo-coin {
    width: 28px;
    height: 28px;
    font-size: 11px;
  }
  .logo-text {
    font-size: 15px;
    white-space: nowrap;
    letter-spacing: 0.02em;
  }
  .btn-head {
    min-height: 40px;
    padding: 4px 8px;
    font-size: 13px;
    white-space: nowrap;
  }
  .play-head {
    gap: 8px;
    margin-bottom: 2px;
  }
  .btn-back {
    min-height: 40px;
    padding: 4px 10px;
    font-size: 14px;
  }
  .play-title {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    column-gap: 8px;
    min-width: 0;
  }
  .play-title h1 {
    font-size: 18px;
  }
  .play-record {
    font-size: 12px;
  }
  .play-goal {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
  }
  .cabinet {
    --board-w: min(100%, var(--board-fit, 280px));
    padding: 6px 8px 8px;
    border-width: 3px;
  }
  .cab-plate {
    margin-bottom: 4px;
    font-size: 13px;
  }
  .hud {
    margin: 6px 0 0;
  }
  .hud-item {
    padding: 1px 6px;
  }
  .hud-value {
    font-size: 15px;
  }
  .msg {
    margin: 2px 0 4px;
    min-height: 1.4em;
    line-height: 1.4;
  }
  .panel {
    gap: 6px;
    padding: 6px;
  }
  .coin-row {
    gap: 6px;
  }
  .btn-coin {
    padding: 4px 8px 4px 6px;
    gap: 6px;
    font-size: 13px;
  }
  .coin-label {
    line-height: 1.2;
    text-align: left;
  }
  .btn-start {
    min-width: 64px;
    padding: 4px 8px;
    font-size: 15px;
    letter-spacing: 0.02em;
  }
  .btn-ctl {
    min-width: 58px;
    min-height: 52px;
    padding: 4px 6px;
  }
  .ctl-lever {
    min-width: 64px;
    min-height: 60px;
  }
  .ctl-wide {
    min-width: 120px;
  }
  .ctl-num {
    min-width: 44px;
    min-height: 44px;
  }
  .ctl-label {
    font-size: 14px;
  }
}

/* タッチ端末ではキー表示を省く */
@media (hover: none) {
  .ctl-sub-key {
    display: none;
  }
}

@media (max-width: 520px) {
  .msg {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

.coin-label {
  white-space: nowrap;
}

/* ---------- 中央揃え ---------- */
.play {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.play-head,
.play-goal {
  width: 100%;
  max-width: 980px;
}

.play-head {
  justify-content: center;
  position: relative;
}

.play-head .btn-back {
  position: absolute;
  left: 0;
}

.play-goal {
  text-align: center;
}

.play-body {
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.howto {
  width: 100%;
  max-width: 640px;
  flex: none;
}

@media (max-width: 759px) {
  .play-head {
    justify-content: flex-start;
  }
  .play-head .btn-back {
    position: static;
  }
  .play-goal {
    text-align: left;
  }
}

/* ---------- PC：盤面を中央に大きく、操作部を左右に置く ---------- */
@media (min-width: 760px) {
  main {
    max-width: none;
    padding-top: 8px;
  }
  .play-goal {
    margin: 2px 0 8px;
  }
  .cabinet {
    display: grid;
    grid-template-columns: 180px auto 180px;
    grid-template-rows: auto auto auto 1fr auto;
    grid-template-areas:
      "plate plate plate"
      "hud   board coin"
      "lctl  board cext"
      "lfill board rctl"
      ".     msg   .";
    column-gap: 16px;
    width: auto;
    max-width: 100%;
    padding: 10px 16px 10px;
  }
  .panel,
  .ctl-center {
    display: contents;
  }
  .cab-plate {
    grid-area: plate;
    font-size: 16px;
    margin-bottom: 8px;
  }
  .board-wrap {
    grid-area: 2 / 2 / 5 / 3;
    width: var(--board-fit, 420px);
  }
  .hud {
    grid-area: hud;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    margin: 0 0 12px;
  }
  .hud-item {
    padding: 4px 10px;
  }
  .hud-label {
    font-size: 12px;
  }
  .hud-value {
    font-size: 24px;
  }
  .msg {
    grid-area: msg;
    margin: 8px 0 0;
    font-size: 15px;
  }
  .ctl-left {
    grid-area: lctl;
    align-self: start;
  }
  .coin-row {
    grid-area: coin;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 14px;
  }
  .ctl-center-extra {
    grid-area: cext;
    align-self: start;
    margin-bottom: 14px;
  }
  .ctl-right {
    grid-area: rctl;
    align-self: start;
  }
  .btn-coin {
    min-height: 64px;
    justify-content: center;
    font-size: 16px;
  }
  .coin-slot {
    height: 40px;
    width: 12px;
  }
  .btn-start {
    min-height: 60px;
    font-size: 20px;
  }
  .ctl-lever {
    min-height: 150px;
    font-size: 17px;
  }
  .ctl-lever .ctl-label {
    font-size: 18px;
  }
  .ctl-wide {
    min-width: 0;
    min-height: 80px;
  }
  .ctl-wide .ctl-label {
    font-size: 18px;
  }
  .ctl-center-extra:has(.ctl-num) {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }
  .ctl-num {
    min-width: 0;
    min-height: 54px;
  }
  .panel[data-layout="dpad"] .ctl-center-extra {
    grid-template-columns: repeat(3, 54px);
    grid-template-rows: repeat(2, 54px);
  }
  .ctl-center-extra:empty,
  .ctl-left:empty,
  .ctl-right:empty {
    display: none;
  }
}

@media (min-width: 760px) {
  .ctl-center-extra {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (min-width: 760px) {
  .cabinet {
    grid-template-rows: auto auto auto 1fr;
    grid-template-areas:
      "hud   board coin"
      "lctl  board cext"
      "msg   board rctl"
      ".     board .";
    padding: 14px 16px;
  }
  .cab-plate {
    display: none;
  }
  .board-wrap {
    grid-area: 1 / 2 / 5 / 3;
  }
  .msg {
    align-self: start;
    margin: 4px 0 0;
    min-height: 0;
    text-align: left;
    white-space: normal;
    font-size: 14px;
    line-height: 1.5;
  }
  .play-head {
    margin-bottom: 0;
  }
}

/* スマホ：見出しと重複する台の名札を省き、盤面を大きく */
@media (max-width: 759px) {
  .cab-plate {
    display: none;
  }
  .cabinet {
    padding-top: 8px;
  }
  .ctl-lever .ctl-label {
    font-size: 13px;
    white-space: nowrap;
  }
}
