/* demo-game-studio — a small, framework-free stylesheet shared by the
   lobby, play, and replay pages (see render/*.ts). Kept as plain CSS
   (no build step, no preprocessor) to match the studio's own
   zero-runtime-dependency posture. */

:root {
  --bg: #10131a;
  --panel: #1a1f2b;
  --panel-border: #2c3344;
  --text: #e8ecf4;
  --text-muted: #9aa4bb;
  --accent: #f4b93f;
  --accent-strong: #ffcf5c;
  --win: #4ddc8a;
  --danger: #ff6b6b;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: radial-gradient(circle at top, #1c2233 0%, var(--bg) 60%);
  color: var(--text);
  max-width: 900px;
  margin: 0 auto;
  padding: 2rem 1.25rem 4rem;
}

h1 {
  font-size: 1.9rem;
  margin-bottom: 0.25rem;
}

a {
  color: var(--accent);
}

code {
  background: rgba(255, 255, 255, 0.08);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
}

/* ---- Lobby ------------------------------------------------------- */

.lobby > p {
  color: var(--text-muted);
  max-width: 640px;
  line-height: 1.5;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.25rem;
  margin-top: 1.5rem;
}

.game-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.game-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
}

.game-card-art {
  font-size: 2.25rem;
  text-align: center;
  padding: 1rem 0;
  border-radius: var(--radius);
  background: linear-gradient(160deg, rgba(244, 185, 63, 0.18), rgba(244, 185, 63, 0.04));
}

.game-card h2 {
  margin: 0;
  font-size: 1.15rem;
}

.game-card-description {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 0;
  flex-grow: 1;
}

.game-card-rtp {
  font-size: 0.8rem;
  color: var(--accent);
  margin: 0;
  letter-spacing: 0.02em;
}

.game-card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

/* dialog.embed is #embed-view — a native <dialog> shown via
   .showModal() (see client/lobby.ts), which promotes it (and everything
   inside it) above the rest of the page in the browser's top layer. A
   closed <dialog> is display:none by the UA stylesheet with no extra CSS
   needed, so this only has to style the OPEN state. */
dialog.embed {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: none;
  background: #000;
}

dialog.embed::backdrop {
  background: #000;
}

dialog.embed #game-frame {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 0;
  display: block;
}

#game-frame {
  width: 100%;
  height: 640px;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  background: #000;
}

/* The corner overlay ("遮罩") shown on top of the game while its dialog
   is open — balance + the shell's own back/log controls. Lives INSIDE
   the dialog (see render/lobby-page.ts): content outside a <dialog>
   renders behind it once open, so this has to be a child to stay
   reachable. */
.shell-overlay {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 5;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-width: 200px;
  background: rgba(26, 31, 43, 0.92);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  backdrop-filter: blur(6px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.shell-overlay-balance {
  color: var(--text-muted);
  font-size: 0.85rem;
}

.shell-overlay-balance span {
  color: var(--accent);
  font-weight: 700;
}

.shell-overlay-actions {
  display: flex;
  gap: 0.5rem;
}

.shell-overlay-actions button {
  flex: 1;
  font-size: 0.78rem;
  padding: 0.4rem 0.6rem;
  white-space: nowrap;
  background: transparent;
  border-color: var(--panel-border);
  color: var(--text-muted);
  font-weight: 500;
}

.shell-overlay-actions button:hover {
  border-color: var(--text-muted);
  color: var(--text);
  background: transparent;
}

/* The shell-level bridge-event log, toggled by .shell-overlay's "View
   Log" button — positioned as its own panel below the corner overlay
   rather than inside it, since it can grow tall; .log (shared with the
   per-game logs) supplies the font/border/scroll styling, this only
   repositions it as a fixed corner panel instead of an inline block. */
#shell-log {
  position: fixed;
  top: 6.5rem;
  right: 1rem;
  z-index: 5;
  width: 320px;
  max-width: calc(100vw - 2rem);
  max-height: 45vh;
  margin-top: 0;
}

/* ---- Buttons ------------------------------------------------------ */

button, .play-button {
  font: inherit;
  cursor: pointer;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 0.6rem 1.25rem;
  background: var(--accent);
  color: #1a1200;
  font-weight: 600;
  transition: background 0.15s ease, opacity 0.15s ease, transform 0.1s ease;
  text-decoration: none;
  display: inline-block;
}

button:hover, .play-button:hover {
  background: var(--accent-strong);
}

button:active, .play-button:active {
  transform: scale(0.97);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.play-button.secondary {
  background: transparent;
  border-color: var(--panel-border);
  color: var(--text);
}

.play-button.secondary:hover {
  border-color: var(--accent);
  background: rgba(244, 185, 63, 0.1);
}

#exit-button, #decline-test-button, #rollback-test-button {
  background: transparent;
  border-color: var(--panel-border);
  color: var(--text-muted);
  font-weight: 500;
}

#exit-button:hover, #decline-test-button:hover, #rollback-test-button:hover {
  border-color: var(--text-muted);
  color: var(--text);
}

.back-link {
  color: var(--text-muted);
  font-size: 0.85rem;
  display: inline-block;
  margin-bottom: 0.75rem;
}

/* ---- Play / replay panel ------------------------------------------ */

.game {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 1.5rem;
  max-width: 640px;
}

.game-description {
  color: var(--text-muted);
  margin-top: 0;
}

.balance {
  font-size: 1.1rem;
  margin: 0.75rem 0;
}

.balance span {
  color: var(--accent);
  font-weight: 700;
}

.config-info p {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0.15rem 0;
}

.reels {
  font-size: 3rem;
  display: flex;
  gap: 0.6rem;
  margin: 1.25rem 0;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.35);
  border-radius: var(--radius);
  border: 1px solid var(--panel-border);
  justify-content: center;
  transition: box-shadow 0.2s ease;
}

.reels.reels--won {
  box-shadow: 0 0 0 2px var(--win), 0 0 22px rgba(77, 220, 138, 0.5) inset;
}

.reel {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.25rem;
  height: 3.25rem;
  background: var(--panel);
  border-radius: 8px;
  border: 1px solid var(--panel-border);
}

.free-spins-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: linear-gradient(120deg, rgba(244, 185, 63, 0.22), rgba(244, 185, 63, 0.06));
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.free-spins-panel strong {
  color: var(--accent-strong);
  font-size: 1.1rem;
}

.controls, .test-controls {
  margin: 1rem 0;
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-wrap: wrap;
}

.test-controls p {
  width: 100%;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin: 0 0 0.25rem;
}

label {
  color: var(--text-muted);
  font-size: 0.9rem;
}

input[type='number'] {
  font: inherit;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.45rem 0.6rem;
  width: 6rem;
}

.log {
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 0.8rem;
  max-height: 220px;
  overflow-y: auto;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
  margin-top: 1.25rem;
  background: rgba(0, 0, 0, 0.35);
  color: var(--text-muted);
}

.paytable {
  border-collapse: collapse;
  margin: 1.25rem 0;
  width: 100%;
  font-size: 0.9rem;
}

.paytable th, .paytable td {
  border: 1px solid var(--panel-border);
  padding: 0.4rem 0.75rem;
  text-align: left;
}

.paytable th {
  color: var(--text-muted);
  font-weight: 600;
  background: rgba(255, 255, 255, 0.03);
}

select {
  font: inherit;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--panel-border);
  color: var(--text);
  border-radius: 6px;
  padding: 0.4rem 0.5rem;
}
