:root {
  --ink: #17152b;
  --panel: #282345;
  --panel-2: #37305a;
  --cream: #fff5d6;
  --mint: #77e6c2;
  --pink: #ff6f91;
  --yellow: #ffd65a;
  --blue: #6fbcff;
  --shadow: #0b0a16;
  --tile: 4px;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  overflow-x: hidden;
  background:
    linear-gradient(rgba(255,255,255,.025) 50%, transparent 50%) 0 0 / 100% 4px,
    radial-gradient(circle at 20% 0%, #3b315d 0, #17152b 48%, #0d0c19 100%);
  color: var(--cream);
  font-family: "Courier New", ui-monospace, monospace;
  image-rendering: pixelated;
}

button, input, select { font: inherit; }

button {
  border: 3px solid var(--shadow);
  border-radius: 0;
  background: var(--yellow);
  color: var(--ink);
  font-weight: 900;
  box-shadow: 4px 4px 0 var(--shadow);
  cursor: pointer;
}

button:hover { filter: brightness(1.08); transform: translate(-1px, -1px); }
button:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--shadow); }
button:disabled { opacity: .46; cursor: not-allowed; filter: grayscale(.3); }

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

.app-shell {
  min-height: 100dvh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pixel-hud {
  min-height: 78px;
  display: grid;
  grid-template-columns: auto minmax(220px, 1fr) auto auto;
  align-items: center;
  gap: 18px;
  padding: 10px clamp(12px, 3vw, 34px);
  border-bottom: 4px solid var(--shadow);
  background: rgba(23, 21, 43, .95);
  box-shadow: 0 6px 0 rgba(0,0,0,.2);
  position: relative;
  z-index: 10;
}

.home-link {
  color: var(--mint);
  text-decoration: none;
  font-size: 13px;
  font-weight: 900;
}

.brand-block p, .brand-block h1 { margin: 0; }
.brand-block p { color: var(--pink); font-size: 10px; font-weight: 900; letter-spacing: .24em; }
.brand-block h1 { color: var(--cream); font-size: clamp(17px, 2.3vw, 27px); line-height: 1.1; text-shadow: 3px 3px 0 #7f3e72; }

.player-summary { display: flex; flex-wrap: wrap; gap: 9px; font-size: 12px; font-weight: 800; }
.player-summary span { padding: 6px 8px; border: 2px solid #62577e; background: #201d36; }
.player-summary span:nth-child(2) { color: var(--yellow); }

.hud-actions { display: flex; gap: 8px; }
.hud-actions button { min-height: 38px; padding: 6px 10px; font-size: 11px; }
.hud-actions button:first-child { background: var(--mint); }
#bubble-toggle { background: var(--blue); }
#bubble-toggle[aria-pressed="false"] { background: #8d849e; color: #272139; }

.game-layout {
  width: min(1460px, 100%);
  min-height: calc(100dvh - 78px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 14px;
  padding: 14px;
  flex: 1;
}

.game-stage {
  position: relative;
  min-width: 0;
  min-height: min(720px, calc(100dvh - 106px));
  overflow: hidden;
  border: 4px solid var(--shadow);
  background: #121126;
  box-shadow: 8px 8px 0 rgba(0,0,0,.28);
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: min(720px, calc(100dvh - 106px));
  object-fit: cover;
  image-rendering: pixelated;
  outline: none;
  touch-action: none;
}

.stage-topline {
  position: absolute;
  top: 10px;
  left: 10px;
  right: 10px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
}

.stage-topline span, .stage-hint {
  padding: 7px 9px;
  border: 3px solid var(--shadow);
  background: rgba(23,21,43,.9);
  color: var(--cream);
  font-size: 11px;
  font-weight: 900;
  box-shadow: 3px 3px 0 rgba(0,0,0,.35);
}

#zone-label { color: var(--mint); }
#nearby-label { color: var(--yellow); text-align: right; }
.stage-hint { position: absolute; left: 10px; bottom: 10px; color: #c7bedc; pointer-events: none; }

.chat-panel {
  align-self: stretch;
  min-height: 0;
  border: 4px solid var(--shadow);
  background: var(--panel);
  box-shadow: 8px 8px 0 rgba(0,0,0,.28);
  display: flex;
  flex-direction: column;
}

.chat-toggle {
  width: 100%;
  min-height: 46px;
  border: 0;
  border-bottom: 4px solid var(--shadow);
  background: var(--pink);
  box-shadow: none;
  text-align: left;
  padding: 0 13px;
}
.chat-toggle span { float: right; }
.chat-body { min-height: 0; flex: 1; display: flex; flex-direction: column; }
.chat-messages { flex: 1; min-height: 260px; max-height: calc(100dvh - 190px); overflow: auto; padding: 12px; }
.chat-message { margin: 0 0 12px; font-size: 12px; line-height: 1.45; overflow-wrap: anywhere; }
.chat-message strong { color: var(--mint); }
.chat-message time { display: block; color: #8f86a6; font-size: 9px; }
.chat-form { display: grid; grid-template-columns: 1fr auto; gap: 7px; padding: 9px; border-top: 3px solid var(--shadow); }
.chat-form input { min-width: 0; border: 3px solid var(--shadow); background: var(--cream); color: var(--ink); padding: 9px; font-size: 12px; }
.chat-form button { padding: 7px; font-size: 10px; }
.chat-panel.is-collapsed .chat-body { display: none; }

.mobile-controls { display: none; }

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(7,6,16,.78);
  backdrop-filter: blur(3px);
}

.pixel-modal {
  width: min(760px, 100%);
  max-height: min(88dvh, 900px);
  overflow: auto;
  border: 5px solid var(--shadow);
  background: var(--panel);
  box-shadow: 10px 10px 0 rgba(0,0,0,.55);
  animation: modal-pop 160ms steps(3, end);
}

@keyframes modal-pop { from { transform: scale(.9); opacity: 0; } to { transform: scale(1); opacity: 1; } }

.modal-head { position: sticky; top: 0; z-index: 2; display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 4px solid var(--shadow); background: #4b3c72; }
.modal-head h2 { margin: 0; color: var(--yellow); font-size: clamp(17px, 3vw, 24px); text-shadow: 2px 2px 0 var(--shadow); }
.modal-close { width: 38px; height: 34px; padding: 0; background: var(--pink); }
.modal-body { padding: 16px; }
.modal-copy { color: #d6cee9; font-size: 12px; line-height: 1.65; }
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.modal-actions button { min-height: 42px; padding: 8px 15px; }
.modal-actions .secondary { background: #a69bbf; }
.modal-actions .danger { background: var(--pink); }

.machine-hero { display: grid; grid-template-columns: 170px 1fr; gap: 18px; align-items: center; margin-bottom: 16px; }
.machine-art-img { display: block; width: 160px; height: 190px; margin: auto; object-fit: contain; image-rendering: pixelated; filter: drop-shadow(7px 8px 0 rgba(0,0,0,.3)); }
.machine-title p { margin: 5px 0; }
.cost-chip { display: inline-block; padding: 7px 10px; border: 3px solid var(--shadow); background: var(--yellow); color: var(--ink); font-weight: 900; }

.figure-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.figure-card { position: relative; border: 3px solid var(--shadow); background: #332d51; padding: 10px; box-shadow: 4px 4px 0 rgba(0,0,0,.28); }
.figure-card.is-selected { outline: 4px solid var(--mint); background: #3f4770; }
.figure-card img { width: 100%; aspect-ratio: 1; object-fit: contain; background: #19172d; border: 2px solid #5c5275; image-rendering: pixelated; }
.figure-mystery { width: 100%; aspect-ratio: 1; display: grid; place-items: center; border: 2px solid #e6d277; background: repeating-linear-gradient(135deg, #17152b 0 14px, #332d51 14px 28px); color: #fff7a1; font-size: clamp(58px, 9vw, 104px); font-weight: 900; text-shadow: 5px 5px 0 #6d5a20; }
.figure-card.is-secret { background: #27223f; box-shadow: 0 0 0 3px #fff7a1, 6px 6px 0 rgba(0,0,0,.4); }
.figure-card h3 { min-height: 2.4em; margin: 7px 0 3px; color: var(--cream); font-size: 12px; line-height: 1.2; }
.figure-origin { min-height: 30px; display: flex; align-items: center; gap: 5px; margin: 5px 0 7px; padding: 5px 6px; border: 2px solid #17152b; background: #211d39; color: var(--yellow); font-size: 9px; line-height: 1.2; font-weight: 900; }
.figure-origin span { flex: 0 0 auto; padding: 2px 4px; background: var(--mint); color: var(--ink); font-size: 8px; }
.figure-meta { display: flex; justify-content: space-between; gap: 5px; color: #bfb6d4; font-size: 10px; }
.figure-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 3px 7px; margin-top: 7px; color: #d8d1e8; font-size: 9px; }
.rarity { color: var(--rarity, var(--cream)); font-weight: 900; }
.figure-card button { width: 100%; margin-top: 9px; padding: 7px 4px; font-size: 10px; }

.inventory-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: end; margin-bottom: 12px; padding: 10px; border: 3px solid var(--shadow); background: #211d39; }
.inventory-toolbar label { display: grid; flex: 1 1 210px; gap: 5px; color: var(--mint); font-size: 10px; font-weight: 900; }
.inventory-toolbar select { min-height: 38px; border: 3px solid var(--shadow); background: var(--cream); color: var(--ink); padding: 5px; }
.empty-state { border: 3px dashed #655a82; padding: 28px 15px; text-align: center; color: #bdb4d0; }

.draw-stage { min-height: 500px; display: grid; place-items: center; text-align: center; overflow: hidden; position: relative; background: radial-gradient(circle, #584a7a, #201c38 68%); }
.draw-machine-rig { position: relative; width: min(390px, 88vw); height: 430px; display: grid; place-items: start center; padding-top: 8px; }
.draw-machine-image { width: 300px; height: 390px; object-fit: contain; image-rendering: pixelated; filter: drop-shadow(10px 12px 0 rgba(0,0,0,.36)); user-select: none; pointer-events: none; }
.draw-machine-rig.is-ready .draw-machine-image { animation: machine-bob .9s steps(4) infinite; }
.draw-machine-rig.is-dispensing .draw-machine-image { animation: machine-shake .11s steps(2) 8; }
.lever-console { position: absolute; left: 69%; top: 58%; width: 138px; display: grid; justify-items: center; gap: 5px; padding: 8px 8px 7px; border: 4px solid var(--shadow); background: linear-gradient(135deg, #d8d4c8, #77727c 48%, #eee9d8 49% 56%, #8b8790 57%); box-shadow: inset 0 0 0 3px #f7f0d4, 7px 8px 0 rgba(0,0,0,.38); transform: translate(-50%, -50%); z-index: 2; }
.lever-console strong { width: 100%; padding: 4px 5px; border: 2px solid var(--shadow); background: var(--yellow); color: var(--ink); font-size: 9px; box-shadow: 2px 2px 0 rgba(0,0,0,.35); }
.coin-accept { width: 100%; display: flex; align-items: center; justify-content: center; gap: 7px; padding: 4px; border: 2px solid #393440; background: #22202a; color: #82f0c7; font-size: 7px; font-weight: 900; letter-spacing: .04em; }
.coin-accept small::before { content: ''; display: inline-block; width: 6px; height: 6px; margin-right: 4px; border: 1px solid #0b0a16; border-radius: 50%; background: #72f0a8; box-shadow: 0 0 6px #72f0a8; animation: coin-led .8s steps(2) infinite; }
@keyframes coin-led { 50% { opacity: .45; } }
.coin-slot-mark { width: 30px; height: 8px; border: 2px solid #0b0a16; background: #77727c; box-shadow: inset 0 0 0 2px #17151d; }
.lever-housing { position: relative; width: 112px; height: 112px; display: grid; place-items: center; border: 5px solid #17151d; border-radius: 50%; background: repeating-conic-gradient(from -7.5deg, #4f4b54 0 5deg, #b9b4aa 5deg 10deg, #716c75 10deg 15deg); box-shadow: inset 0 0 0 5px #ded8c8, inset 0 0 0 10px #6c6870; }
.lever-housing::after { content: '↻'; position: absolute; right: -9px; bottom: -7px; width: 27px; height: 27px; display: grid; place-items: center; border: 2px solid #17151d; border-radius: 50%; background: var(--yellow); color: var(--ink); font-size: 18px; font-weight: 900; }
.lever-dial { --lever-angle: 0deg; position: relative; width: 86px; height: 86px; border: 4px solid #17151d; border-radius: 50%; background: radial-gradient(circle, #d8d2c4 0 20%, #68636d 21% 45%, #aaa59d 46% 61%, #56515b 62%); box-shadow: inset 0 0 0 3px #eee8d8, 3px 4px 0 rgba(0,0,0,.38); cursor: grab; touch-action: none; user-select: none; }
.lever-dial:active { cursor: grabbing; }
.lever-dial.is-locked { cursor: default; filter: brightness(.78) saturate(.7); }
.lever-rotor { position: absolute; inset: 0; transform: rotate(var(--lever-angle)); transition: transform 35ms linear; pointer-events: none; }
.lever-spoke { position: absolute; left: 50%; top: 50%; width: 14px; height: 40px; margin-left: -7px; margin-top: -36px; border: 3px solid #17151d; border-radius: 5px; background: linear-gradient(90deg, #77717a, #e5dfcf 48%, #69646d 52%); transform-origin: 50% 36px; }
.lever-spoke i { position: absolute; left: 50%; top: -11px; width: 25px; height: 24px; border: 3px solid #17151d; border-radius: 8px; background: linear-gradient(#f18362, #a73f46); box-shadow: inset 4px 3px 0 rgba(255,255,255,.25); transform: translateX(-50%); }
.lever-spoke.spoke-a { transform: rotate(0deg); }
.lever-spoke.spoke-b { transform: rotate(120deg); }
.lever-spoke.spoke-c { transform: rotate(240deg); }
.lever-center-cap { position: absolute; left: 50%; top: 50%; width: 31px; height: 31px; border: 4px solid #17151d; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff7df 0 15%, #aaa49a 16% 42%, #5e5962 43%); transform: translate(-50%, -50%); box-shadow: 2px 2px 0 rgba(0,0,0,.32); }
.lever-screw { position: absolute; width: 9px; height: 9px; border: 2px solid #17151d; border-radius: 50%; background: #d8d2c4; z-index: 3; }
.lever-screw::after { content: ''; position: absolute; left: 1px; right: 1px; top: 2px; height: 1px; background: #3f3b43; transform: rotate(45deg); }
.screw-a { left: 5px; top: 11px; }.screw-b { right: 5px; top: 11px; }.screw-c { left: 5px; bottom: 11px; }.screw-d { right: 5px; bottom: 11px; }
.lever-progress { position: absolute; left: 18%; right: 18%; bottom: 15px; height: 13px; border: 3px solid var(--shadow); background: #161326; }
.lever-progress span { display: block; width: 0; height: 100%; background: repeating-linear-gradient(90deg, var(--mint) 0 12px, #4cb795 12px 15px); transition: width 80ms linear; }
@keyframes machine-bob { 50% { transform: translateY(-5px); } }
@keyframes machine-shake { 50% { transform: translateX(7px) rotate(1deg); } }
.draw-instruction { position: absolute; left: 10px; right: 10px; bottom: 6px; margin: 0; color: var(--yellow); font-weight: 900; font-size: 12px; animation: blink .8s steps(2) infinite; }
@keyframes blink { 50% { opacity: .35; } }

.result-card { text-align: center; }
.result-burst { position: relative; display: inline-grid; place-items: center; width: min(300px, 80vw); aspect-ratio: 1; background: repeating-conic-gradient(from 0deg, var(--rarity-color) 0 12deg, transparent 12deg 24deg); animation: burst 4s linear infinite; }
.result-burst::before { content: ''; position: absolute; inset: 18%; border-radius: 50%; background: var(--panel); }
.result-burst img { position: relative; z-index: 1; width: 64%; image-rendering: pixelated; filter: drop-shadow(7px 7px 0 rgba(0,0,0,.4)); }
@keyframes burst { to { transform: rotate(360deg); } }
.result-card h3 { margin: 6px 0; font-size: 25px; color: var(--rarity-color); }
.result-origin { width: fit-content; max-width: 330px; margin: 7px auto 10px; }
.result-card .figure-stats { max-width: 330px; margin: 10px auto; grid-template-columns: repeat(4,1fr); font-size: 11px; }
.flash-SSR, .flash-UR, .flash-SECRET { animation: rare-flash .55s ease-out 3; }
@keyframes rare-flash { 45% { background: #fff; } }

.auth-tabs { display: flex; gap: 8px; margin-bottom: 14px; }
.auth-tabs button { flex: 1; padding: 9px; background: #a89ebb; }
.auth-tabs button.is-active { background: var(--mint); }
.pixel-form { display: grid; gap: 10px; }
.pixel-form label { display: grid; gap: 5px; color: #cfc7df; font-size: 11px; }
.pixel-form input { min-height: 44px; border: 3px solid var(--shadow); background: var(--cream); color: var(--ink); padding: 9px; font-size: 16px; }
.form-error { min-height: 1.4em; color: #ff9aae; font-size: 11px; }

.trainer-banner { display: grid; grid-template-columns: 96px 1fr; align-items: center; gap: 14px; margin-bottom: 14px; }
.trainer-avatar { width: 72px; height: 96px; display: block; margin: auto; border: 4px solid var(--shadow); background-color: var(--blue); background-repeat: no-repeat; background-size: 400% 400%; background-position: 0 0; image-rendering: pixelated; box-shadow: 5px 5px 0 rgba(0,0,0,.25); }
.trainer-banner h3, .trainer-banner p { margin: 4px 0; }
.team-counter { color: var(--yellow); font-weight: 900; }

.battle-board { display: grid; gap: 12px; }
.battle-side { display: grid; grid-template-columns: 90px 1fr; gap: 11px; align-items: center; border: 3px solid var(--shadow); padding: 9px; background: #211d39; }
.battle-side.enemy { grid-template-columns: 1fr 90px; text-align: right; }
.battle-side img { width: 90px; height: 90px; object-fit: contain; image-rendering: pixelated; }
.hp-track { height: 14px; border: 3px solid var(--shadow); background: #3b334b; }
.hp-fill { height: 100%; width: 100%; background: var(--mint); transition: width .25s steps(5); }
.dice-row { display: flex; justify-content: center; gap: 10px; margin: 8px 0; }
.die { width: 48px; height: 48px; display: grid; place-items: center; border: 4px solid var(--shadow); background: var(--cream); color: var(--ink); font-size: 21px; font-weight: 900; box-shadow: 4px 4px 0 rgba(0,0,0,.35); }
.die.is-rolling { animation: die-roll .12s steps(2) infinite; }
@keyframes die-roll { 50% { transform: translateY(-5px) rotate(5deg); } }
.battle-log { height: 120px; overflow: auto; border: 3px solid var(--shadow); background: #12101f; padding: 9px; color: #c8c0d8; font-size: 10px; line-height: 1.55; }
.battle-log p { margin: 0 0 4px; }

.toast-region { position: fixed; z-index: 200; right: 14px; bottom: 14px; display: grid; gap: 8px; pointer-events: none; }
.toast { max-width: 330px; border: 3px solid var(--shadow); background: var(--mint); color: var(--ink); padding: 11px 13px; box-shadow: 5px 5px 0 rgba(0,0,0,.4); font-size: 12px; font-weight: 900; animation: toast-in .2s steps(3); }
.toast.error { background: var(--pink); }
@keyframes toast-in { from { transform: translateX(110%); } }

@media (max-width: 980px) {
  .pixel-hud { grid-template-columns: auto 1fr auto; gap: 10px; }
  .player-summary { grid-column: 1 / -1; order: 3; justify-content: center; }
  .game-layout { grid-template-columns: 1fr; padding: 8px; min-height: 0; }
  .game-stage, #game-canvas { min-height: 0; height: 100%; }
  .chat-panel { position: fixed; z-index: 40; right: 8px; bottom: 8px; width: min(310px, calc(100vw - 16px)); max-height: 52dvh; }
  .chat-panel.is-collapsed { width: 150px; }
  .chat-messages { min-height: 150px; max-height: 30dvh; }
  .mobile-controls { position: absolute; inset: auto 14px 14px; display: flex; align-items: flex-end; justify-content: space-between; pointer-events: none; }
  .dpad { width: 150px; height: 150px; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); gap: 2px; }
  .dpad button, .interact-button { pointer-events: auto; touch-action: none; opacity: .88; min-width: 48px; min-height: 48px; padding: 0; background: rgba(255,245,214,.9); }
  .dpad-up { grid-column: 2; }
  .dpad-left { grid-column: 1; grid-row: 2; }
  .dpad-center { grid-column: 2; grid-row: 2; opacity: .5 !important; }
  .dpad-right { grid-column: 3; grid-row: 2; }
  .dpad-down { grid-column: 2; grid-row: 3; }
  .interact-button { width: 90px; height: 58px; margin-bottom: 25px; background: rgba(255,111,145,.94); }
  .stage-hint { display: none; }
}

@media (max-width: 620px) {
  .pixel-hud { min-height: 108px; grid-template-columns: auto 1fr; align-items: center; }
  .home-link { font-size: 10px; }
  .brand-block h1 { font-size: 17px; }
  .hud-actions { grid-column: 1 / -1; justify-content: center; }
  .hud-actions button { flex: 1; max-width: 180px; }
  .player-summary { display: grid; grid-template-columns: repeat(3,1fr); width: 100%; gap: 4px; font-size: 9px; }
  .player-summary span { padding: 5px 3px; text-align: center; }
  .game-stage, #game-canvas { min-height: 0; height: 100%; }
  .stage-topline { top: 6px; left: 6px; right: 6px; }
  .stage-topline span { max-width: 52%; font-size: 9px; }
  .mobile-controls { inset: auto 8px 8px; }
  .dpad { width: 132px; height: 132px; }
  .dpad button { min-width: 42px; min-height: 42px; }
  .chat-panel { bottom: 5px; right: 5px; }
  .machine-hero { grid-template-columns: 1fr; text-align: center; }
  .draw-stage { min-height: 450px; }
  .draw-machine-rig { width: min(340px, 92vw); height: 390px; }
  .draw-machine-image { width: 270px; height: 350px; }
  .lever-console { left: 70%; top: 57%; transform: translate(-50%, -50%) scale(.86); }
  .figure-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .modal-backdrop { padding: 7px; }
  .pixel-modal { max-height: 94dvh; }
  .modal-body { padding: 11px; }
  .result-card .figure-stats { grid-template-columns: repeat(2, 1fr); }
  .battle-side, .battle-side.enemy { grid-template-columns: 70px 1fr; text-align: left; }
  .battle-side.enemy img { grid-row: 1; }
  .battle-side img { width: 68px; height: 68px; }
}

@media (min-width: 981px) and (hover: hover) and (pointer: fine) {
  .mobile-controls { display: none; }
}

/* Plaza / workshop expansion */
.pixel-hud { grid-template-columns: auto 1fr auto; }
.hud-actions { flex-wrap: wrap; }
.hud-actions button { font-size: .75rem; }
.avatar-options { display: grid; grid-template-columns: repeat(5,minmax(0,1fr)); gap: 12px; }
.avatar-options button { display: grid; justify-items: center; gap: 12px; background: #2b2947; color: #fff5d6; border-color: #696480; min-width: 0; padding: 18px 6px; }
.avatar-preview { display: block; width: 72px; height: 96px; background-size: 400% 400%; background-position: 0 0; image-rendering: pixelated; }
.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 240px; gap: 24px; align-items: start; }
#avatar-editor { display: block; width: 100%; max-width: 480px; aspect-ratio: 1; image-rendering: pixelated; touch-action: none; border: 3px solid #99ced5; background-color: #35334c; background-image: conic-gradient(#4d4a65 25%, transparent 0 50%, #4d4a65 0 75%, transparent 0); background-size: 20px 20px; }
.editor-tools { display: grid; gap: 10px; font-size: 1rem; }
.editor-tools label { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.editor-tools input[type=color] { width: 70px; height: 42px; padding: 3px; }
.editor-tools select { max-width: 150px; padding: 8px; }
.service-intro { text-align: center; font-size: 1rem; line-height: 1.8; }
.service-symbol { display: inline-block; color: #83efc9; font: bold 3rem monospace; border: 3px solid #83efc9; padding: 16px 24px; margin: 18px; }
.battle-portrait { position: relative; isolation: isolate; }
.battle-portrait .battle-effect { position: absolute; inset: -10%; width: 120%; height: 120%; object-fit: contain; z-index: 2; animation: effect-flash .7s ease-out forwards; }
.floating-damage { position: absolute; z-index: 3; top: -20px; left: 50%; white-space: nowrap; color: #fff5ba; text-shadow: 2px 2px #6d2545, -2px -2px #6d2545; font: bold 1.6rem monospace; pointer-events: none; animation: damage-rise .9s ease-out forwards; }
.battle-portrait.is-hit > img:first-child { animation: damage-shake .35s ease; }
.modal-copy, .pixel-form label { font-size: 1rem; line-height: 1.6; }
.figure-origin, .figure-meta, .figure-stats { font-size: .8125rem; }
@keyframes damage-rise { from { transform: translate(-50%,0); opacity: 1; } to { transform: translate(-50%,-52px); opacity: 0; } }
@keyframes effect-flash { from { transform: scale(.5); opacity: 1; } to { transform: scale(1.35); opacity: 0; } }
@keyframes damage-shake { 20%,60% { transform: translateX(-7px); } 40%,80% { transform: translateX(7px); } }
@media (max-width: 980px) { .pixel-hud { grid-template-columns: auto 1fr; } .hud-actions { justify-content: flex-end; } }
@media (max-width: 620px) {
  .pixel-hud { grid-template-columns: 1fr; }
  .brand-block { text-align: center; }
  .hud-actions { justify-content: center; }
  .avatar-options { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .editor-layout { grid-template-columns: 1fr; }
  .editor-tools { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .editor-tools .modal-copy { grid-column: 1 / -1; }
  .battle-side.enemy .battle-portrait { grid-column: 1; grid-row: 1; }
  .battle-side.enemy > div:not(.battle-portrait) { grid-column: 2; grid-row: 1; }
}
@media (prefers-reduced-motion: reduce) { .battle-effect, .floating-damage, .battle-portrait.is-hit > img:first-child { animation-duration: .01ms; } }

/* Static, external display slots. Actual Google ads never live inside the game canvas/modal. */
:root { --arcade-ad-gap: 24px; }
:root.arcade-live-ads { --arcade-ad-gap: 160px; }
.app-shell { height: auto; overflow: visible; }
.arcade-ad-box { display: flex; flex-direction: column; align-items: center; gap: 8px; flex: none; }
.ad-label { font: 400 .875rem sans-serif; color: #b9b2ca; }
.arcade-ad-frame { display: flex; align-items: center; justify-content: center; background: #17172b; outline: 1px solid #4c4864; flex: none; }
.arcade-chat-ad .arcade-ad-frame { width: 320px; height: 100px; }
.ad-placeholder { color: #9d97af; font: .875rem sans-serif; text-align: center; padding: 12px; }
.ad-placeholder[hidden] { display: none; }
.arcade-ad-frame ins { flex: none; }
.game-layout { width: min(1800px, 100%); min-height: 0; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--arcade-ad-gap); align-items: start; }
.game-stage { height: clamp(460px, 66dvh, 760px); min-height: 0; }
#game-canvas { height: 100%; min-height: 0; object-fit: fill; }
.game-sidebar { display: flex; flex-direction: column; gap: var(--arcade-ad-gap); min-width: 0; }
:root.arcade-live-ads .game-sidebar { padding-top: 160px; }
.game-sidebar .chat-panel { position: static; width: 100%; max-height: none; }
.game-sidebar .chat-messages { min-height: 160px; max-height: 280px; }
#modal-root { position: absolute; inset: 0; z-index: 70; pointer-events: none; }
#modal-root > * { pointer-events: auto; }
#modal-root .modal-backdrop { position: absolute; inset: 0; padding: 12px; overflow: auto; }
#modal-root .pixel-modal { max-height: 100%; width: 100%; }
.sponsor-detail { display: grid; justify-items: center; gap: 18px; font: 1rem/1.6 sans-serif; }
.sponsor-detail img { display: block; width: 100%; max-width: 640px; height: auto; aspect-ratio: 2; object-fit: contain; }
.sponsor-detail a { color: #9af3d8; padding: 12px 18px; border: 2px solid #669789; }
@media (max-width: 1100px) {
  .game-layout { grid-template-columns: 1fr; }
  .game-sidebar { width: 100%; max-width: 640px; justify-self: center; }
  .game-stage { height: max(460px, 65dvh); }
  .game-sidebar .chat-panel.is-collapsed { width: 100%; }
}

/* Mechanical capsule handle: cream cabinet, blue/yellow ring and white cross-grip. */
.lever-console { background: #ecebe6; border-color: #aaa79c; color: #203b67; border-radius: 10px; }
.coin-accept { position: relative; height: 75px; display: block; background: transparent; border: 0; }
.coin-in-arrow { position: absolute; left: 4px; top: 8px; padding: 5px 8px; border-radius: 20px 5px 5px 20px; background: #1b5d8c; color: white; font: bold 12px sans-serif; }
.coin-slot-round { position: absolute; right: 5px; top: 0; width: 62px; height: 62px; border: 2px solid #b9b0a1; border-radius: 50%; background: #f6f5ef; box-shadow: inset 3px 2px 6px #bcb9af, 1px 1px white; }
.coin-slot-round i { position: absolute; width: 5px; height: 44px; left: 27px; top: 7px; background: #59463c; border-radius: 60%; transform: rotate(-3deg); }
.coin-accept small { position: absolute; left: 4px; bottom: 0; font-size: 10px; color: #355071; }
.inserted-coin { position: absolute; right: 15px; top: -10px; width: 34px; height: 34px; display: grid; place-items: center; background: #e5b649; border: 3px ridge #ffe59b; border-radius: 50%; color: #946d20; opacity: 0; z-index: 5; }
@keyframes insert-coin { 0% { opacity: 1; transform: translate(30px,-22px) scaleX(1); } 55% { opacity: 1; transform: translate(-8px,20px) scaleX(.25); } 100% { opacity: 0; transform: translate(-8px,33px) scaleX(.08) scaleY(.6); } }
.lever-housing { background: #e8e7e1; border: 0; border-radius: 50%; box-shadow: none; }
.lever-screw { display: none; }
.lever-dial { border-radius: 50%; background: #214576; border: 6px solid #183f70; box-shadow: inset 0 0 0 5px #efd939, 1px 3px 5px #aaa; }
.lever-dial::before { content: '↻'; position: absolute; right: 3px; top: 37%; color: #e8d93d; font-size: 25px; }
.lever-dial[aria-disabled="true"] { cursor: wait; }
.lever-rotor { position: absolute; inset: 13px; transform: rotate(var(--lever-angle,0deg)); background: transparent; border: 0; border-radius: 50%; }
.lever-white-knob { position: absolute; inset: 0; border-radius: 50%; background: radial-gradient(circle at 38% 25%,white,#e7e8e2 65%,#bcbeb9); border: 2px solid #c3c5bf; box-shadow: inset 2px 3px 5px white,2px 5px 8px #192f52; }
.lever-grip-bar { position: absolute; top: 38%; left: -5%; width: 110%; height: 25%; border-radius: 5px; background: linear-gradient(white,#f8f8f3 45%,#cccfc8 65%,#f9f9f3); border: 1px solid #c4c7bf; box-shadow: 0 5px 6px #8d938f; }
.game-sidebar .chat-messages { min-height: 360px; max-height: 60dvh; overflow-y: auto; overflow-wrap: anywhere; }
#online-status { padding: 8px 10px; margin: 0; font: 12px/1.5 sans-serif; color: #a7efd6; }
.machine-search { display: block; min-height: 40px; width: 100%; padding: 8px; margin-bottom: 5px; }
.editor-link { color: #a7efd6; font: 12px sans-serif; justify-self: end; }
.lever-console { width: 164px; }
.lever-housing { width: 122px; height: 122px; }
.lever-dial { width: 112px; height: 112px; }
.lever-housing::after,.coin-accept small::before { display: none; }
.lever-rotor { transition: none; }
.inventory-toolbar label { min-width: 180px; }
@media(max-width:620px) { .game-sidebar .chat-messages { min-height: 280px; max-height: 55dvh; } }
@media (max-width: 359px) {
  .arcade-chat-ad .arcade-ad-frame { max-width: calc(100vw - 32px); }
}
