/* Design tokens */
:root {
  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-text: #0f172a;
  --color-muted: #475569;
  --color-primary: #1e40af;
  --color-primary-hover: #1d4ed8;
  --color-border: #cbd5e1;
  --color-error: #dc2626;
  --shadow: 0 1px 2px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.1);
  --radius: 12px;
  --spacing: 16px;
  --font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Noto Sans JP", "Hiragino Kaku Gothic ProN", "BIZ UDGothic", Meiryo, sans-serif;
  --fs-base: clamp(14px, 1.2vw + 10px, 18px);
  --fs-h1: clamp(20px, 2vw + 16px, 28px);
  --fs-h2: clamp(18px, 1.4vw + 14px, 22px);

  /* Dark mode tokens */
  --color-bg-dark: #0b1222;
  --color-surface-dark: #0f172a;
  --color-text-dark: #e5e7eb;
  --color-muted-dark: #9ca3af;
  --color-primary-dark: #3b82f6;
  --color-primary-hover-dark: #60a5fa;
  --color-border-dark: #334155;
}

html, body { height: 100%; }
html { scroll-behavior: smooth; }

/* Use dynamic viewport unit for mobile URL bar collapse */
:root { --vh: 1vh; }
.app-main { min-height: calc(var(--vh) * 100 - 60px); }

body {
  font-family: var(--font-family);
  background-color: var(--color-bg);
  color: var(--color-text);
  margin: 0;
  line-height: 1.6;
  font-size: var(--fs-base);
  -webkit-tap-highlight-color: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
}

body.dark {
  --color-bg: var(--color-bg-dark);
  --color-surface: var(--color-surface-dark);
  --color-text: var(--color-text-dark);
  --color-muted: var(--color-muted-dark);
  --color-primary: var(--color-primary-dark);
  --color-primary-hover: var(--color-primary-hover-dark);
  --color-border: var(--color-border-dark);
}

.app-main {
  width: 100%;
  max-width: 1100px;
  padding: 16px clamp(16px, 4vw, 32px) 32px;
  display: flex;
  flex-direction: column;
  gap: clamp(16px, 4vw, 32px);
  align-items: center;
}
/* 以前の2カラムは廃止し、常に1カラムで上部をゲームに占有させる */

.app-main > * {
  width: 100%;
}

.game-panel, .settings-panel, .side-panel {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: clamp(12px, 2vw, 20px);
  box-shadow: var(--shadow);
}

.slot-container { display: grid; grid-auto-flow: row; justify-items: center; gap: 8px; width: 100%; }
.top-hud { display: grid; grid-auto-flow: row; justify-items: center; gap: 6px; margin-bottom: 8px; }
.top-hud .credit-panel { position: static; left: auto; top: auto; transform: none; }
.top-hud .meter-panel { position: static; left: auto; top: auto; transform: none; }
.reel-frame {
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: clamp(8px, 2vw, 16px);
  --marqueeH: clamp(16px, 3vw, 24px);
  padding: calc(var(--marqueeH) + 10px) clamp(14px, 3vw, 20px) clamp(10px, 2vw, 16px);
  border-radius: 16px;
  background:
    radial-gradient(120% 120% at 50% 30%, rgba(255,90,0,.18), rgba(255,0,0,0) 60%),
    linear-gradient(180deg, #1a1f2b, #0f1420);
  border: 3px solid #2b3445;
  box-shadow: inset 0 2px 8px rgba(0,0,0,.5), 0 10px 24px rgba(0,0,0,.35);
}

/* Digital credit display (top) */
.credit-panel {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  display: inline-grid;
  grid-auto-flow: row;
  gap: 2px;
  align-items: center;
  justify-items: center;
  padding: 6px 10px;
  min-width: clamp(120px, 28vw, 200px);
  border-radius: 8px;
  background: radial-gradient(120% 120% at 50% 50%, rgba(0,0,0,.65), rgba(0,0,0,.4));
  border: 1px solid rgba(255,255,255,.08);
  box-shadow: inset 0 2px 8px rgba(0,0,0,.6), 0 2px 8px rgba(0,0,0,.3);
  z-index: 4; /* above hibiscus background, below reels */
}
.credit-label {
  font-size: 10px;
  letter-spacing: 0.28em;
  color: rgba(255,255,255,.55);
  font-weight: 700;
}
.digit-display {
  font-variant-numeric: tabular-nums;
  font-family: "Segoe UI Mono", Consolas, Menlo, monospace;
  font-size: clamp(22px, 6vw, 42px);
  line-height: 1;
  letter-spacing: 0.08em;
  color: #1cff76;
  text-shadow:
    0 0 6px rgba(0,255,120,.88),
    0 0 14px rgba(0,180,90,.75),
    0 0 26px rgba(0,140,70,.6);
  filter: saturate(1.2) brightness(1.05);
}

/* Stats meters under the credit */
.meter-panel {
  position: absolute;
  top: 44px;
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(90px, 1fr);
  gap: 6px;
  z-index: 4;
}
.meter-box { display: grid; justify-items: center; gap: 2px; padding: 4px 6px; background: rgba(0,0,0,.35); border: 1px solid rgba(255,255,255,.08); border-radius: 6px; box-shadow: inset 0 2px 8px rgba(0,0,0,.5); }
.meter-label { font-size: 10px; color: rgba(255,255,255,.66); letter-spacing: .12em; font-weight: 700; }
.meter-label.red { color: #ff6b6b; }
.meter-label.orange { color: #ffb85c; }
.meter-label.cyan { color: #60a5fa; }
.digit-small { font-family: "Segoe UI Mono", Consolas, Menlo, monospace; font-variant-numeric: tabular-nums; font-size: clamp(14px, 3.6vw, 18px); color: #a7f3d0; text-shadow: 0 0 6px rgba(34,197,94,.9), 0 0 12px rgba(16,185,129,.7); }
.digit-small.red { color: #ff6666; text-shadow: 0 0 6px rgba(255,80,80,.9), 0 0 12px rgba(200,50,50,.7); }
.digit-small.orange { color: #ffb85c; text-shadow: 0 0 6px rgba(255,184,92,.9), 0 0 12px rgba(220,120,50,.7); }
.digit-small.cyan { color: #7dd3fc; text-shadow: 0 0 6px rgba(125,211,252,.9), 0 0 12px rgba(59,130,246,.7); }
.digit-display.ping { animation: digit-ping .28s ease-out 1; }
@keyframes digit-ping {
  0% { filter: saturate(1.2) brightness(1.05); text-shadow: 0 0 8px rgba(0,255,120,.9), 0 0 14px rgba(0,180,90,.8), 0 0 26px rgba(0,140,70,.65); }
  50% { filter: saturate(1.6) brightness(1.35); text-shadow: 0 0 12px rgba(0,255,120,1), 0 0 22px rgba(0,220,120,.95), 0 0 38px rgba(0,180,90,.85); }
  100% { filter: saturate(1.2) brightness(1.05); }
}
.slot-machine { display: inline-flex; justify-content: center; align-items: center; gap: clamp(8px, 2vw, 16px); position: relative; z-index: 5; }
.game-panel, .reel-frame, .slot-machine { cursor: pointer; }
.reel {
  width: clamp(72px, 12vw, 120px);
  height: clamp(108px, 18vw, 180px);
  border: 2px solid #3b4457;
  background: linear-gradient(180deg, #eef0f5, #cfd6e0);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-radius: 10px;
  box-shadow: inset 0 2px 10px rgba(0,0,0,.25), 0 2px 6px rgba(0,0,0,.25);
}
.reel-content { display: flex; flex-direction: column; }
.reel span {
  height: calc(100% / 3);
  display: grid;
  place-items: center;
  font-size: clamp(24px, 4vw, 36px);
  font-weight: 700;
  user-select: none;
}
.reel span.bar { background: #111827; color: #fff; border-radius: 6px; padding: 2px 8px; letter-spacing: .08em; }
.seven {
  /* Bold, vivid pink 7 with dark outline (high contrast) */
  font-family: "Arial Black", Impact, var(--font-family);
  font-weight: 900;
  font-size: clamp(28px, 5.2vw, 46px);
  color: #ff39b4; /* vivid pink */
  /* Dark outline for readability on light reel */
  -webkit-text-stroke: 2.2px #1a0a1a;
  text-shadow:
    -1px -1px 0 #1a0a1a,
     1px -1px 0 #1a0a1a,
    -1px  1px 0 #1a0a1a,
     1px  1px 0 #1a0a1a,
     0px  2px 4px rgba(0,0,0,.35),
     0px -1px 0 rgba(255,255,255,.65);
}

.message { font-weight: 700; margin-top: 8px; min-height: 1.6em; opacity: 0; transform: translateY(6px); transition: opacity .25s ease, transform .25s ease; }
.message.show { opacity: 1; transform: translateY(0); }
.message.error { color: var(--color-error); }
.coin { margin-top: 4px; color: var(--color-muted); font-weight: 600; }

.controls { display: flex; justify-content: center; flex-wrap: wrap; gap: 12px; margin-top: 10px; }
button { min-height: 44px; min-width: 44px; padding: 10px 16px; font-size: 1rem; background: var(--color-primary); color: #fff; border: none; border-radius: 999px; cursor: pointer; box-shadow: var(--shadow); transition: background .2s, transform .06s;
}
button.primary { font-weight: 700; }
@media (hover: hover) { button:hover:not(:disabled) { background: var(--color-primary-hover); transform: translateY(-1px); } }
button:active { transform: translateY(0); }
button:disabled { background: var(--color-border); cursor: not-allowed; box-shadow: none; }
button:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

.button-like { background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); border-radius: 10px; padding: 8px 12px; }
.select-like { background: var(--color-surface); color: var(--color-text); border: 1px solid var(--color-border); border-radius: 10px; padding: 8px 12px; min-height: 40px; }

/* Hibiscus */
.hibiscus-side {
  position: relative;
  width: clamp(64px, 12vw, 112px);
  height: clamp(64px, 12vw, 112px);
  background: radial-gradient(circle at 50% 50%, rgba(255,0,0,0.08) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
  isolation: isolate; /* layer for ::before/::after z-index */
}
.reel-frame .hibiscus-side { position: absolute; top: -34px; z-index: 2; }
.reel-frame #hibiscus { left: -26px; }
.reel-frame #hibiscus-right { right: -26px; }
.hibiscus-side::after {
  
  /* Leaves behind the flower */
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background: center/contain no-repeat url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><g fill='%2322c55e' opacity='0.95'><ellipse cx='18' cy='62' rx='18' ry='10' transform='rotate(-28 18 62)'/><ellipse cx='82' cy='62' rx='18' ry='10' transform='rotate(28 82 62)'/></g><g fill='%2334d399' opacity='0.45'><ellipse cx='22' cy='60' rx='10' ry='6' transform='rotate(-28 22 60)'/><ellipse cx='78' cy='60' rx='10' ry='6' transform='rotate(28 78 60)'/></g></svg>");
  opacity: .2;
  filter: saturate(.9) brightness(.92);
}
.hibiscus-side::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  background: center/contain no-repeat url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><g fill='%23ff1a1a'><ellipse cx='50' cy='16' rx='18' ry='22'/><ellipse cx='82' cy='34' rx='18' ry='22' transform='rotate(20 82 34)'/><ellipse cx='68' cy='78' rx='18' ry='22' transform='rotate(40 68 78)'/><ellipse cx='32' cy='78' rx='18' ry='22' transform='rotate(-40 32 78)'/><ellipse cx='18' cy='34' rx='18' ry='22' transform='rotate(-20 18 34)'/></g><circle cx='50' cy='52' r='12' fill='%23ffd84d'/><circle cx='54' cy='48' r='4' fill='%23ffffff' opacity='0.7'/></svg>");
  opacity: .18;
  filter: saturate(.7) brightness(.95);
  transition: opacity .2s ease, filter .2s ease, transform .2s ease;
}
.hibiscus-side.glowing,
.hibiscus-side.glow-normal {
  background: radial-gradient(circle at 50% 50%, rgba(255,0,0,0.35) 0%, rgba(255,0,0,0.22) 40%, transparent 75%);
  box-shadow: 0 0 14px rgba(255,0,0,0.65), 0 0 32px rgba(255,0,0,0.5), 0 0 60px rgba(255,0,0,0.35);
  animation: hibiscus-blink .44s steps(2, jump-none) infinite, pulse-glow 1.1s ease-in-out infinite;
}
.hibiscus-side.glowing::before,
.hibiscus-side.glow-normal::before,
.hibiscus-side.glow-strobe::before,
.hibiscus-side.glow-breathe::before,
.hibiscus-side.glow-wave::before,
.hibiscus-side.glow-twinkle::before,
.hibiscus-side.glow-steady::before,
.hibiscus-side.glow-ultraslow::before,
.hibiscus-side.glow-rotate::before,
.hibiscus-side.glow-leaf::before,
.hibiscus-side.glowing::after,
.hibiscus-side.glow-normal::after,
.hibiscus-side.glow-strobe::after,
.hibiscus-side.glow-breathe::after,
.hibiscus-side.glow-wave::after,
.hibiscus-side.glow-twinkle::after,
.hibiscus-side.glow-steady::after,
.hibiscus-side.glow-ultraslow::after,
.hibiscus-side.glow-leaf::after {
  opacity: 1;
  filter: saturate(1.25) brightness(1.1) drop-shadow(0 0 6px rgba(255,0,0,.55)) drop-shadow(0 0 14px rgba(255,0,0,.4));
}
.hibiscus-side.glow-strobe {
  background: radial-gradient(circle at 50% 50%, rgba(255,0,0,0.45) 0%, rgba(255,0,0,0.28) 40%, transparent 75%);
  box-shadow: 0 0 18px rgba(255,0,0,0.8), 0 0 46px rgba(255,0,0,0.6), 0 0 72px rgba(255,0,0,0.45);
  animation: strobe 0.18s steps(2, jump-none) infinite;
}
.hibiscus-side.glow-breathe {
  background: radial-gradient(circle at 50% 50%, rgba(255,0,0,0.32) 0%, rgba(255,0,0,0.2) 40%, transparent 75%);
  box-shadow: 0 0 18px rgba(255,0,0,0.6), 0 0 38px rgba(255,0,0,0.45);
  animation: pulse-glow 1.6s ease-in-out infinite;
}
.hibiscus-side.glow-wave {
  background: radial-gradient(circle at 50% 50%, rgba(255,0,0,0.36) 0%, rgba(255,0,0,0.24) 40%, transparent 75%);
  box-shadow: 0 0 16px rgba(255,0,0,0.7), 0 0 40px rgba(255,0,0,0.5);
  animation: hibiscus-blink .44s steps(2, jump-none) infinite;
}
.hibiscus-side.wave-a { animation-delay: 0s; }
.hibiscus-side.wave-b { animation-delay: .22s; }
.hibiscus-side.glow-twinkle {
  background: radial-gradient(circle at 50% 50%, rgba(255,0,0,0.4) 0%, rgba(255,0,0,0.26) 40%, transparent 75%);
  box-shadow: 0 0 20px rgba(255,0,0,0.78), 0 0 56px rgba(255,0,0,0.55);
  animation: twinkle 0.12s steps(2, jump-none) infinite, pulse-glow 1.2s ease-in-out infinite;
}
.hibiscus-side.glow-steady {
  background: radial-gradient(circle at 50% 50%, rgba(255,0,0,0.5) 0%, rgba(255,0,0,0.28) 40%, transparent 75%);
  box-shadow: 0 0 22px rgba(255,0,0,0.85), 0 0 64px rgba(255,0,0,0.6);
}
.hibiscus-side.glow-ultraslow {
  background: radial-gradient(circle at 50% 50%, rgba(255,0,0,0.35) 0%, rgba(255,0,0,0.22) 40%, transparent 75%);
  animation: hibiscus-blink 2.2s steps(2, jump-none) infinite;
}
.hibiscus-side.flash-red,
.hibiscus-side.flash-blue,
.hibiscus-side.flash-yellow {
  animation: color-flash .42s ease-out 1;
}

@keyframes color-flash {
  0% { box-shadow: 0 0 12px rgba(255,0,0,0.0); filter: brightness(1); }
  20% { box-shadow: 0 0 28px var(--flash-color, rgba(255,0,0,0.9)); filter: brightness(1.2); }
  100% { box-shadow: 0 0 6px rgba(255,0,0,0.0); filter: brightness(1); }
}
.flash-red { --flash-color: rgba(255,60,60,0.95) !important; }
.flash-blue { --flash-color: rgba(80,160,255,0.95) !important; }
.flash-yellow { --flash-color: rgba(255,224,60,0.95) !important; }

/* Premium: rotate the flower */
.hibiscus-side.glow-rotate { animation: pulse-glow 1.2s ease-in-out infinite; }
.hibiscus-side.glow-rotate::before { animation: rotate-hibi 2.6s linear infinite; transform-origin: 50% 50%; }
@keyframes rotate-hibi { from { transform: rotate(0deg);} to { transform: rotate(360deg);} }
/* Ultra premium: leaves-only green blink */
.hibiscus-side.glow-leaf {
  background: radial-gradient(circle at 50% 50%, rgba(16,185,129,0.34) 0%, rgba(16,185,129,0.18) 40%, transparent 75%);
  box-shadow: 0 0 16px rgba(16,185,129,0.7), 0 0 40px rgba(16,185,129,0.5);
}
.hibiscus-side.glow-leaf::before { opacity: .12; filter: saturate(.5) brightness(.7); }
.hibiscus-side.glow-leaf::after { filter: saturate(1.4) brightness(1.25) drop-shadow(0 0 10px rgba(16,185,129,.65)); animation: twinkle 0.14s steps(2, jump-none) infinite, pulse-glow 1.2s ease-in-out infinite; }

/* Premium: center-only yellow glow */
.hibiscus-side.glow-center {
  background: radial-gradient(circle at 50% 50%, rgba(255,216,77,0.35) 0%, rgba(255,216,77,0.22) 40%, transparent 75%);
  box-shadow: 0 0 14px rgba(255,216,77,0.65), 0 0 32px rgba(255,216,77,0.5), 0 0 60px rgba(255,216,77,0.35);
  animation: hibiscus-blink .44s steps(2, jump-none) infinite, pulse-glow 1.1s ease-in-out infinite;
}
.hibiscus-side.glow-center::before {
  background: center/contain no-repeat url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><circle cx='50' cy='52' r='12' fill='%23ffd84d'/><circle cx='54' cy='48' r='4' fill='%23ffffff' opacity='0.7'/></svg>");
}
.hibiscus-side.glow-center::after { opacity: 0; }

/* Premium: three-petal blink */
.hibiscus-side.glow-petal3 {
  background: radial-gradient(circle at 50% 50%, rgba(255,0,0,0.35) 0%, rgba(255,0,0,0.22) 40%, transparent 75%);
  box-shadow: 0 0 14px rgba(255,0,0,0.65), 0 0 32px rgba(255,0,0,0.5), 0 0 60px rgba(255,0,0,0.35);
  animation: hibiscus-blink .44s steps(2, jump-none) infinite, pulse-glow 1.1s ease-in-out infinite;
}
.hibiscus-side.glow-petal3::before {
  background: center/contain no-repeat url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'><g fill='%23ff1a1a'><ellipse cx='50' cy='16' rx='18' ry='22'/><ellipse cx='82' cy='34' rx='18' ry='22' transform='rotate(20 82 34)'/><ellipse cx='18' cy='34' rx='18' ry='22' transform='rotate(-20 18 34)'/></g><circle cx='50' cy='52' r='12' fill='%23ffd84d'/><circle cx='54' cy='48' r='4' fill='%23ffffff' opacity='0.7'/></svg>");
}
@keyframes hibiscus-blink { 0%,100%{opacity:1;} 50%{opacity:.22;} }
@keyframes pulse-glow { 0%{ transform: scale(1);} 50%{ transform: scale(1.08);} 100%{ transform: scale(1);} }
@keyframes strobe { 0%,100%{filter: saturate(1.3) brightness(1.1);} 50%{ filter: saturate(1.3) brightness(0.6);} }
@keyframes twinkle { 0%,100%{opacity:1;} 50%{opacity:.2;} }

/* Reel spin scrolling */
@keyframes spin { 0%{ transform: translateY(0%);} 100%{ transform: translateY(-50%);} }
@keyframes spin-reverse { 0%{ transform: translateY(0%);} 100%{ transform: translateY(50%);} }
@keyframes reel-shake { 0%,100%{ transform: translate(0,0) rotate(0);} 20%{ transform: translate(-1px,1px) rotate(-0.8deg);} 40%{ transform: translate(2px,-1px) rotate(0.6deg);} 60%{ transform: translate(-2px,1px) rotate(-0.6deg);} 80%{ transform: translate(1px,-1px) rotate(0.8deg);} }
.reel-content.glitching { animation: reel-shake .5s steps(6,end); }
.reel-content.reverse { animation: spin-reverse .12s linear infinite; }
.reel-content.stall { animation-play-state: paused !important; }
@keyframes reel-nudge { 0%{ transform: translateY(0);} 50%{ transform: translateY(-8%);} 100%{ transform: translateY(0);} }
.reel-content.nudge { animation: reel-nudge .14s ease-out 1; }

/* Screen flash overlay for premium */
.flash-overlay { position: fixed; inset: 0; background: rgba(255,255,255,0.0); pointer-events: none; z-index: 9999; animation: flash-burst .18s ease-out 1; }
@keyframes flash-burst { 0%{ background: rgba(255,255,255,0); } 30%{ background: rgba(255,255,255,0.9);} 100%{ background: rgba(255,255,255,0);} }

/* Cabinet-like front panel */
.cabinet-panel {
  margin-top: 10px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: linear-gradient(180deg, #2b2f3a, #1b1e27);
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.06);
  box-shadow: inset 0 4px 10px rgba(0,0,0,.35), 0 4px 12px rgba(0,0,0,.2);
}
.cabinet-panel .panel-left, .cabinet-panel .panel-right, .cabinet-panel .panel-center {
  display: inline-flex; align-items: center; gap: 10px; justify-content: center;
}
.cabinet-panel .meter { color: #e5e7eb; font-weight: 700; }
.cabinet-panel .meter strong { font-size: 1.1rem; }

.cabinet-panel .bet {
  background: radial-gradient(circle at 30% 30%, #ff6363, #c81e1e);
  color: #fff; border-radius: 999px; padding: 10px 18px; font-weight: 800; letter-spacing: .06em; box-shadow: 0 4px 8px rgba(0,0,0,.35), inset 0 2px 6px rgba(255,255,255,.25);
}
.cabinet-panel .stop {
  width: 60px; height: 60px; border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #ff4d4d, #b91c1c);
  color: #fff; font-size: 1.1rem; font-weight: 800; border: none; box-shadow: 0 6px 12px rgba(0,0,0,.4), inset 0 3px 8px rgba(255,255,255,.25);
}
.cabinet-panel .stop:disabled { filter: grayscale(.35) brightness(.8); opacity: .7; }

/* Joystick-style lever */
.cabinet-panel .lever.joystick { position: relative; width: 96px; height: 96px; background: none; border: none; box-shadow: none; padding: 0; }
.lever.joystick .lever-base { position: absolute; inset: 2px; border-radius: 50%; background:
  radial-gradient(circle at 50% 50%, #111827 0 24%, transparent 25%),
  conic-gradient(from 200deg, rgba(255,255,255,.18), rgba(255,255,255,0) 60%),
  radial-gradient(circle at 50% 50%, #475569 0 60%, #1f2937 61% 100%);
  box-shadow: inset 0 8px 12px rgba(0,0,0,.35), 0 6px 16px rgba(0,0,0,.35);
}
.lever.joystick .lever-base::after{ content:""; position:absolute; left:50%; top:10%; transform: translateX(-50%); width:26px; height:78%; border-radius: 14px; background: linear-gradient(180deg, rgba(15,23,42,.65), rgba(15,23,42,.25)); box-shadow: inset 0 6px 10px rgba(0,0,0,.35), inset 0 -8px 12px rgba(255,255,255,.08); }
.lever.joystick .lever-stick { position: absolute; left: 50%; top: 16%; width: 18px; height: 60px; transform: translateX(-50%); border-radius: 12px; background: linear-gradient(180deg, #ffffff, #cdd6e1); box-shadow: inset 0 2px 6px rgba(255,255,255,.6), inset 0 -6px 10px rgba(15,23,42,.2); transition: top .16s ease; }
.lever.joystick .lever-ball { position: absolute; left: 50%; top: 56%; transform: translate(-50%, 0); width: 38px; height: 38px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff6, #fff0 42%), radial-gradient(circle at 50% 50%, #ff834d 0, #f97316 60%, #b45309 100%); box-shadow: 0 6px 10px rgba(0,0,0,.35), inset 0 3px 8px rgba(255,255,255,.35); transition: top .16s ease, transform .16s ease; }
.lever.joystick:hover .lever-ball { transform: translate(-50%, 1px) scale(1.02); }
.lever.joystick:active .lever-ball, .lever.joystick.engaged .lever-ball { top: 78%; transform: translate(-50%, 0) scale(.98); }
.lever.joystick:active .lever-stick, .lever.joystick.engaged .lever-stick { top: 34%; }
.lever.joystick:focus-visible { outline: 2px solid #60a5fa; outline-offset: 3px; border-radius: 12px; }

/* How to / Settings */
.howto-list { margin: 0; padding-left: 1.2rem; }
.howto-list li { margin: 4px 0; }
.quests-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.quest-item { display: grid; gap: 4px; }
.quest-title { font-weight: 600; }
.quest-item.completed .quest-title { color: var(--color-muted); text-decoration: line-through; }
.quest-progress { height: 8px; background: var(--color-border); border-radius: 4px; overflow: hidden; }
.quest-progress-bar { height: 100%; background: var(--color-primary); width: 0%; transition: width 0.3s ease; }
.quest-count { font-size: 0.85em; color: var(--color-muted); text-align: right; }
.settings-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
@media (min-width: 520px) { .settings-grid { grid-template-columns: 1fr 1fr; } }
.setting-item { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; align-items: center; padding: 10px; border: 1px dashed var(--color-border); border-radius: 10px; }
.setting-label { color: var(--color-muted); }
.setting-control { text-align: right; }
.setting-control .select-like { min-width: 120px; }

.app-footer {
  text-align: center;
  color: var(--color-muted);
  padding: 16px;
  width: 100%;
  max-width: 1100px;
}

.app-footer .developer-credit::before {
  content: '|';
  margin: 0 8px;
}

.ending-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.9);
  color: #fff;
  text-align: center;
  padding: 40px 20px;
  animation: fade-in 0.8s forwards;
  z-index: 999;
}

.ending-overlay[hidden] {
  display: none;
}

.ending-overlay .credits {
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-size: 1.25rem;
  animation: credits-scroll 5s forwards;
}
.ending-overlay .credits p {
  margin: 0;
  opacity: 0;
  animation: text-fade 0.8s forwards;
}
.ending-overlay .credits p.congrats {
  animation-delay: 0.8s;
}
.ending-overlay .credits p.developer-credit {
  animation-delay: 2.4s;
}

@keyframes text-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes credits-scroll {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

/* Accessibility helpers */
.sr-only { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Responsive layout for very small screens */
  @media (max-width: 600px) {
  .top-hud { gap: 4px; margin-bottom: 6px; }
  .top-hud .credit-panel { min-width: 140px; }
  .top-hud .meter-panel { grid-auto-columns: minmax(64px, 1fr); }

  .reel-frame { --marqueeH: 24px; padding: calc(var(--marqueeH) + 8px) 12px 10px; border-radius: 14px; }
  .reel-frame .hibiscus-side { width: 54px; height: 54px; top: -24px; }
  .reel-frame #hibiscus { left: -12px; }
  .reel-frame #hibiscus-right { right: -12px; }
    
    /* Move/size the credit display for phones */
    .credit-panel { padding: 6px 10px; min-width: 140px; }
    .digit-display { font-size: clamp(26px, 7vw, 38px); }
    /* Hide bottom coin text on phones to avoid duplication */
    .coin { display: none; }
  /* Controls: lever fixed on the right for thumb reachability */
  .cabinet-panel { grid-template-columns: 1fr auto; gap: 10px; }
  .cabinet-panel .panel-center { grid-column: 1; grid-row: 1; justify-content: flex-start; }
  .cabinet-panel .panel-left { grid-column: 1; grid-row: 2; justify-content: flex-start; }
  .cabinet-panel .panel-right { grid-column: 2; grid-row: 1 / span 2; justify-content: flex-end; align-self: center; }
  .cabinet-panel .stop { width: 62px; height: 62px; }
  .cabinet-panel .lever.joystick { width: 92px; height: 92px; }

  .slot-machine { gap: 6px; }
  .reel { width: 86px; height: 156px; }
  .reel span { font-size: 2.2rem; }
}

/* Reduced motion: limit to decorative effects (keep reels functional) */
@media (prefers-reduced-motion: reduce) {
  .hibiscus-side, .message, .cabinet-panel .lever.joystick::before {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
  }
  .hibiscus-side, .message, .cabinet-panel .lever.joystick, button {
    transition-duration: .001ms !important;
  }
  html { scroll-behavior: auto !important; }
  /* Do NOT disable .reel-content spin animation */
  .ending-overlay, .ending-overlay .credits {
    animation: none !important;
    transform: none !important;
  }
}
