:root {
  --bg: #0a0812;
  --panel: #14101f;
  --gold: #e8c547;
  --cyan: #39c5cf;
  --green: #3dd68c;
  --red: #f07178;
  --magenta: #c678dd;
  --text: #e6e1cf;
  --dim: #7a8494;
  --border: #2a2438;
  --felt: #1a5c3a;
  --font-pixel: "Press Start 2P", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-pixel);
  font-size: 10px;
  line-height: 1.6;
}

#game-shell {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(232, 197, 71, 0.08) 0%, transparent 55%),
    var(--bg);
}

#phaser-root canvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  box-shadow: 0 0 0 4px var(--border), 0 12px 48px rgba(0, 0, 0, 0.6);
}

#hud {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: min(100%, 640px);
  padding: 8px 12px;
  pointer-events: none;
  z-index: 10;
}

#hud .hud-link {
  pointer-events: auto;
}

.hud-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  background: rgba(20, 16, 31, 0.92);
  border: 2px solid var(--border);
  padding: 8px 10px;
}

.hud-bar span {
  white-space: nowrap;
}

.bj-dealer-tagline {
  color: var(--dim);
  font-size: 8px;
  margin: 0 0 8px;
  font-style: italic;
}

.hud-chips {
  color: var(--gold);
}

.hud-link {
  color: var(--cyan);
  text-decoration: none;
  white-space: nowrap;
}

.hud-link:hover {
  color: var(--gold);
}

.hud-name {
  color: var(--cyan);
}

.hud-hint {
  color: var(--dim);
  font-size: 8px;
}

#dialogue-overlay,
#blackjack-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

#title-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow: hidden;
}

.title-overlay--intro {
  background:
    radial-gradient(ellipse at 50% 35%, rgba(232, 197, 71, 0.12) 0%, transparent 55%),
    var(--bg);
}

.title-overlay--menu {
  background: rgba(10, 8, 18, 0.88);
  backdrop-filter: blur(4px);
}

#dialogue-overlay[hidden],
#blackjack-overlay[hidden],
#title-overlay[hidden] {
  display: none !important;
}

.dialogue-box {
  width: min(100%, 600px);
  background: var(--panel);
  border: 4px solid var(--text);
  box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.5);
  padding: 16px;
}

.dialogue-speaker {
  color: var(--gold);
  margin-bottom: 12px;
  font-size: 9px;
}

.dialogue-text {
  min-height: 4.8em;
  margin-bottom: 12px;
  font-size: 9px;
}

.dialogue-choices {
  list-style: none;
  margin: 0;
  padding: 0;
}

.dialogue-choices li {
  margin: 6px 0;
}

.dialogue-choices button {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 2px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 8px;
  padding: 8px;
  cursor: pointer;
}

.dialogue-choices button:hover,
.dialogue-choices button:focus {
  border-color: var(--cyan);
  color: var(--cyan);
}

.dialogue-advance {
  color: var(--dim);
  font-size: 8px;
  text-align: right;
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

/* --- Title intro cinematic --- */
.title-intro {
  position: relative;
  width: min(100%, 560px);
  text-align: center;
  padding: 32px 20px;
  opacity: 0;
  transform: scale(0.96);
  transition: opacity 0.45s ease, transform 0.45s ease;
}

.title-intro--play {
  opacity: 1;
  transform: scale(1);
}

.title-intro--out {
  opacity: 0;
  transform: scale(1.03);
  transition: opacity 0.45s ease, transform 0.45s ease;
}

.title-intro-glow {
  position: absolute;
  inset: -20%;
  background: radial-gradient(circle at 50% 40%, rgba(232, 197, 71, 0.18) 0%, transparent 62%);
  animation: titleGlowPulse 2.8s ease-in-out infinite;
  pointer-events: none;
}

.title-intro-content {
  position: relative;
  z-index: 1;
}

.title-intro-eyebrow {
  color: var(--dim);
  font-size: 8px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin: 0 0 12px;
  opacity: 0;
  animation: titleFadeUp 0.7s ease 0.15s forwards;
}

.title-intro-logo {
  color: var(--gold);
  font-size: 16px;
  line-height: 1.5;
  margin: 0 0 16px;
  opacity: 0;
  animation: titleFadeUp 0.8s ease 0.35s forwards, titleLogoShimmer 2.4s ease 1s infinite;
}

.title-intro-rule {
  height: 2px;
  width: 0;
  margin: 0 auto 16px;
  background: linear-gradient(90deg, transparent, var(--gold), var(--cyan), transparent);
  animation: titleRuleDraw 0.9s ease 0.75s forwards;
}

.title-intro-tagline {
  color: var(--magenta);
  font-size: 8px;
  margin: 0 0 24px;
  opacity: 0;
  animation: titleFadeUp 0.7s ease 1s forwards;
}

.title-intro-hint {
  color: var(--dim);
  font-size: 8px;
  margin: 0;
  animation: blink 1.2s step-end infinite;
  opacity: 0;
  animation: titleFadeUp 0.6s ease 1.35s forwards, blink 1.2s step-end 1.8s infinite;
}

.title-intro-chips {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}

.title-intro-chips .chip {
  position: absolute;
  font-size: 14px;
  opacity: 0;
  animation: titleChipFloat 3s ease-in-out infinite;
}

.title-intro-chips .chip-a {
  left: 8%;
  top: 18%;
  color: var(--cyan);
  animation-delay: 0.9s;
}

.title-intro-chips .chip-b {
  right: 10%;
  top: 28%;
  color: var(--gold);
  animation-delay: 1.2s;
}

.title-intro-chips .chip-c {
  left: 50%;
  bottom: 8%;
  color: var(--magenta);
  transform: translateX(-50%);
  animation-delay: 1.5s;
}

@keyframes titleGlowPulse {
  0%, 100% { opacity: 0.55; transform: scale(1); }
  50% { opacity: 1; transform: scale(1.06); }
}

@keyframes titleFadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes titleRuleDraw {
  from { width: 0; opacity: 0.4; }
  to { width: min(240px, 70%); opacity: 1; }
}

@keyframes titleLogoShimmer {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.15); }
}

@keyframes titleChipFloat {
  0% { opacity: 0; transform: translateY(8px); }
  20% { opacity: 0.45; }
  50% { transform: translateY(-6px); }
  80% { opacity: 0.35; }
  100% { opacity: 0.2; transform: translateY(4px); }
}

/* --- Title menu panel --- */
.title-panel--enter {
  opacity: 0;
  transform: translateY(18px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.title-panel--visible {
  opacity: 1;
  transform: translateY(0);
}

.title-resume-block {
  margin: 8px 0 20px;
  padding: 12px;
  border: 2px solid rgba(232, 197, 71, 0.35);
  background: rgba(232, 197, 71, 0.06);
}

.title-resume-label {
  color: var(--gold);
  font-size: 8px;
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.title-resume-btn {
  width: 100%;
  background: linear-gradient(180deg, rgba(232, 197, 71, 0.22) 0%, rgba(232, 197, 71, 0.08) 100%);
  border: 2px solid var(--gold);
  color: var(--gold);
  font-family: inherit;
  font-size: 9px;
  padding: 12px;
  cursor: pointer;
  text-align: center;
  animation: titleResumePulse 2.2s ease-in-out infinite;
}

.title-resume-btn:hover {
  background: rgba(232, 197, 71, 0.28);
  color: var(--text);
}

@keyframes titleResumePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(232, 197, 71, 0.25); }
  50% { box-shadow: 0 0 16px 2px rgba(232, 197, 71, 0.18); }
}

.slot-list--stagger li {
  opacity: 0;
  animation: titleFadeUp 0.45s ease forwards;
}

.slot-list--stagger li:nth-child(1) { animation-delay: 0.08s; }
.slot-list--stagger li:nth-child(2) { animation-delay: 0.14s; }
.slot-list--stagger li:nth-child(3) { animation-delay: 0.2s; }
.slot-list--stagger li:nth-child(4) { animation-delay: 0.26s; }
.slot-list--stagger li:nth-child(5) { animation-delay: 0.32s; }
.slot-list--stagger li:nth-child(6) { animation-delay: 0.38s; }

.slot-list button.active-profile {
  border-color: var(--gold);
  color: var(--gold);
}

.title-input {
  width: 100%;
  padding: 8px;
  margin: 8px 0;
  font-family: inherit;
  font-size: 8px;
  background: #0a0812;
  border: 2px solid #2a2438;
  color: #e6e1cf;
}

.title-panel {
  width: min(100%, 520px);
  background: var(--panel);
  border: 4px solid var(--gold);
  box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.5);
  padding: 20px;
  max-height: 90vh;
  overflow-y: auto;
}

.title-panel h1 {
  color: var(--gold);
  font-size: 14px;
  text-align: center;
  margin: 0 0 8px;
  line-height: 1.4;
}

.title-panel .subtitle {
  color: var(--magenta);
  text-align: center;
  font-size: 8px;
  margin-bottom: 20px;
}

.title-panel h2 {
  color: var(--cyan);
  font-size: 9px;
  margin: 16px 0 8px;
}

.slot-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.slot-list li {
  margin: 6px 0;
}

.slot-list button,
.title-actions button {
  width: 100%;
  background: var(--bg);
  border: 2px solid var(--border);
  color: var(--text);
  font-family: inherit;
  font-size: 8px;
  padding: 10px;
  cursor: pointer;
  text-align: left;
}

.slot-list button:hover,
.title-actions button:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.slot-list .empty {
  color: var(--dim);
}

.title-actions {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.title-link {
  text-align: center;
  margin-top: 12px;
}

.title-link a {
  color: var(--dim);
  font-size: 8px;
}

.blackjack-panel {
  width: min(100%, 640px);
  max-height: 92vh;
  overflow-y: auto;
  background: var(--panel);
  border: 4px solid var(--felt);
  padding: 16px;
}

.blackjack-panel h2 {
  color: var(--gold);
  font-size: 11px;
  text-align: center;
  margin: 0 0 12px;
}

.bj-chip-line {
  color: var(--gold);
  margin-bottom: 8px;
}

.bj-status {
  color: var(--dim);
  font-size: 8px;
  margin-bottom: 12px;
}

.bj-table {
  background: var(--felt);
  border: 2px solid #0d3d28;
  padding: 12px;
  margin-bottom: 12px;
  font-size: 8px;
}

.bj-dealer {
  border-bottom: 1px dashed rgba(255, 255, 255, 0.2);
  padding-bottom: 8px;
  margin-bottom: 8px;
}

.bj-row {
  margin: 4px 0;
}

.bj-row.highlight {
  color: var(--cyan);
}

.bj-log {
  background: var(--bg);
  border: 2px solid var(--border);
  padding: 8px;
  max-height: 120px;
  overflow-y: auto;
  margin-bottom: 12px;
  font-size: 8px;
}

.bj-log .success { color: var(--green); }
.bj-log .error { color: var(--red); }
.bj-log .dim { color: var(--dim); }

.bj-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.bj-actions button,
.bj-form input {
  font-family: inherit;
  font-size: 8px;
}

.bj-actions button {
  background: var(--bg);
  border: 2px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  cursor: pointer;
}

.bj-actions button.primary {
  border-color: var(--gold);
  color: var(--gold);
}

.bj-actions button:hover {
  border-color: var(--cyan);
  color: var(--cyan);
}

.bj-form {
  margin-bottom: 12px;
}

.bj-form label {
  display: block;
  margin-bottom: 6px;
  font-size: 8px;
}

.bj-form input {
  width: 100%;
  background: var(--bg);
  border: 2px solid var(--border);
  color: var(--text);
  padding: 8px;
}

@media (max-width: 480px) {
  html, body { font-size: 8px; }
  .title-panel h1 { font-size: 11px; }
  .hud-bar {
    gap: 6px;
  }
  .hud-hint {
    display: none;
  }
  .hud-name,
  .hud-chips {
    max-width: 42%;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}
