:root {
  --bg: #0a0618;
  --cabinet: #1a1028;
  --neon-pink: #ff2d95;
  --neon-cyan: #00f0ff;
  --neon-yellow: #ffe600;
  --neon-green: #39ff14;
  --screen: #050818;
  --text: #e8f0ff;
  --font: "Press Start 2P", monospace;
  --display: "Orbitron", sans-serif;
}

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

html {
  width: 100%;
  max-width: 100%;
  overflow-x: clip;
}

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

body {
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, #3a1560 0%, transparent 55%),
    radial-gradient(ellipse 60% 40% at 80% 100%, #0a3a4a 0%, transparent 50%),
    var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: max(0.5rem, env(safe-area-inset-top)) max(0.5rem, env(safe-area-inset-right)) max(0.75rem, env(safe-area-inset-bottom)) max(0.5rem, env(safe-area-inset-left));
  overflow-x: clip;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.scanlines {
  pointer-events: none !important;
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  max-width: 100vw;
  overflow: hidden;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.15) 0px,
    rgba(0, 0, 0, 0.15) 1px,
    transparent 1px,
    transparent 3px
  );
  mix-blend-mode: multiply;
}

.crt-glow {
  pointer-events: none !important;
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  max-width: 100vw;
  overflow: hidden;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0, 0, 0, 0.45) 100%);
}

.machine {
  width: 100%;
  max-width: 560px;
  box-sizing: border-box;
  background: linear-gradient(180deg, #2a1840 0%, var(--cabinet) 40%, #120a1c 100%);
  border: 4px solid #4a2a6a;
  border-radius: 28px 28px 18px 18px;
  box-shadow:
    0 0 0 4px #0d0814,
    0 0 24px rgba(255, 45, 149, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.12);
  padding: 1rem 1.1rem 1.25rem;
  position: relative;
  z-index: 2;
  pointer-events: auto;
  overflow: hidden;
  animation: cabinet-in 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes cabinet-in {
  from { opacity: 0; transform: translateY(24px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.cabinet-top {
  text-align: center;
  margin-bottom: 1rem;
}

.marquee {
  position: relative;
  overflow: hidden;
  width: 100%;
  max-width: 100%;
  background: #000;
  border: 2px solid var(--neon-yellow);
  border-radius: 6px;
  padding: 0.45rem 0;
  margin-bottom: 0.9rem;
  box-shadow: 0 0 12px rgba(255, 230, 0, 0.4);
  contain: paint;
}

.marquee-text {
  display: block;
  width: max-content;
  max-width: none;
  white-space: nowrap;
  color: var(--neon-yellow);
  font-size: 0.55rem;
  letter-spacing: 0.12em;
  will-change: transform;
  animation: scroll-marquee 16s linear infinite;
  padding-left: 0;
}

@keyframes scroll-marquee {
  from { transform: translateX(100%); }
  to { transform: translateX(-100%); }
}

.logo {
  margin: 0;
  line-height: 1.15;
}

.logo-line {
  display: block;
  font-family: var(--display);
  font-size: clamp(0.75rem, 3.2vw, 1.1rem);
  letter-spacing: 0.2em;
  color: var(--neon-cyan);
  text-shadow: 0 0 10px var(--neon-cyan);
  overflow-wrap: anywhere;
}

.logo-main {
  display: block;
  font-size: clamp(1.45rem, 8vw, 2.4rem);
  color: var(--neon-pink);
  text-shadow:
    0 0 8px var(--neon-pink),
    0 0 24px var(--neon-pink),
    3px 3px 0 #4a0030;
  margin: 0.25rem 0;
  animation: neon-pulse 2.2s ease-in-out infinite;
  letter-spacing: 0.04em;
}

@keyframes neon-pulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.25); }
}

.screen {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  background: var(--screen);
  border: 3px solid #1e3a5f;
  border-radius: 12px;
  padding: 1.4rem 1rem 1.5rem;
  min-height: 320px;
  box-shadow: inset 0 0 40px rgba(0, 240, 255, 0.08);
}

.screen.active {
  display: flex;
  animation: screen-on 0.35s ease;
}

@keyframes screen-on {
  from { opacity: 0.4; filter: brightness(1.8); }
  to { opacity: 1; filter: brightness(1); }
}

.welcome-msg {
  margin: 0;
  font-size: 0.7rem;
  color: var(--neon-green);
  text-shadow: 0 0 8px var(--neon-green);
}

.blink {
  animation: blink 1.1s step-end infinite;
}

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

.prompt {
  margin: 0;
  font-size: 0.58rem;
  line-height: 1.6;
  text-align: center;
  color: var(--neon-cyan);
  text-shadow: 0 0 6px var(--neon-cyan);
}

.initials {
  display: flex;
  gap: 0.65rem;
  margin: 0.5rem 0;
}

.slot {
  width: 64px;
  height: 72px;
  font-family: var(--font);
  font-size: 1.6rem;
  color: var(--neon-yellow);
  background: #0c1228;
  border: 3px solid var(--neon-pink);
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 0 14px rgba(255, 45, 149, 0.45);
  text-shadow: 0 0 8px var(--neon-yellow);
  transition: transform 0.1s, border-color 0.15s;
}

.slot:hover,
.slot.active {
  transform: translateY(-3px);
  border-color: var(--neon-cyan);
  box-shadow: 0 0 18px rgba(0, 240, 255, 0.55);
}

.hint {
  margin: 0;
  font-size: 0.42rem;
  line-height: 1.7;
  opacity: 0.7;
  text-align: center;
  max-width: 280px;
}

.arcade-btn {
  font-family: var(--font);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  color: #120a1c;
  background: var(--neon-green);
  border: none;
  border-radius: 8px;
  padding: 0.9rem 1.4rem;
  cursor: pointer;
  box-shadow:
    0 0 16px rgba(57, 255, 20, 0.5),
    0 5px 0 #1a8a0a;
  margin-top: 0.4rem;
  transition: transform 0.08s, box-shadow 0.08s;
}

.arcade-btn:active {
  transform: translateY(4px);
  box-shadow: 0 0 10px rgba(57, 255, 20, 0.4), 0 1px 0 #1a8a0a;
}

.arcade-btn.ghost {
  background: transparent;
  color: var(--neon-cyan);
  box-shadow: none;
  border: 2px solid var(--neon-cyan);
  font-size: 0.5rem;
  padding: 0.7rem 1rem;
}

.arcade-btn.ghost:active {
  transform: translateY(2px);
}

.player-tag {
  margin: 0;
  font-size: 0.55rem;
  color: var(--neon-yellow);
  text-shadow: 0 0 8px var(--neon-yellow);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
}

.game-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
}

.game-card {
  display: grid;
  grid-template-columns: auto 1fr auto;
  grid-template-rows: auto auto;
  gap: 0.15rem 0.75rem;
  align-items: center;
  text-decoration: none;
  color: inherit;
  background: linear-gradient(135deg, #121a38 0%, #1a0f30 100%);
  border: 2px solid var(--neon-cyan);
  border-radius: 10px;
  padding: 0.85rem 0.9rem;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.2);
  cursor: pointer;
  pointer-events: auto;
  position: relative;
  z-index: 3;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.game-card:nth-child(2) {
  border-color: var(--neon-pink);
  box-shadow: 0 0 12px rgba(255, 45, 149, 0.25);
}

.game-card:nth-child(3) {
  border-color: var(--neon-green);
  box-shadow: 0 0 12px rgba(57, 255, 20, 0.2);
}

.game-card:nth-child(4) {
  border-color: #c084fc;
  box-shadow: 0 0 12px rgba(192, 132, 252, 0.25);
}

.game-card:hover {
  transform: scale(1.02);
  box-shadow: 0 0 22px rgba(0, 240, 255, 0.45);
}

.game-card:nth-child(2):hover {
  box-shadow: 0 0 22px rgba(255, 45, 149, 0.5);
}

.game-card:nth-child(3):hover {
  box-shadow: 0 0 22px rgba(57, 255, 20, 0.45);
}

.game-card:nth-child(4):hover {
  box-shadow: 0 0 22px rgba(192, 132, 252, 0.5);
}

.game-icon {
  grid-row: 1 / 3;
  font-size: 1.8rem;
  filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.4));
}

.game-name {
  font-size: 0.58rem;
  color: #fff;
  letter-spacing: 0.04em;
}

.game-desc {
  font-size: 0.38rem;
  opacity: 0.7;
  line-height: 1.5;
}

.game-tag {
  grid-row: 1 / 3;
  font-size: 0.38rem;
  color: var(--screen);
  background: var(--neon-yellow);
  padding: 0.35rem 0.4rem;
  border-radius: 4px;
  align-self: center;
}

.cabinet-foot {
  display: flex;
  justify-content: space-between;
  margin-top: 0.9rem;
  font-size: 0.4rem;
  opacity: 0.55;
  letter-spacing: 0.06em;
}

.player-pts {
  color: var(--neon-green);
  text-shadow: 0 0 8px var(--neon-green);
  font-size: 0.5rem;
}

.ranking-panel {
  margin-top: 0.85rem;
  background: #050818;
  border: 2px solid var(--neon-yellow);
  border-radius: 12px;
  padding: 0.75rem 0.7rem 0.85rem;
  box-shadow: 0 0 14px rgba(255, 230, 0, 0.2);
}

.ranking-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.55rem;
}

.ranking-head h2 {
  margin: 0;
  font-size: 0.55rem;
  color: var(--neon-yellow);
  text-shadow: 0 0 8px rgba(255, 230, 0, 0.55);
  letter-spacing: 0.06em;
}

.rank-refresh {
  font-family: var(--font);
  font-size: 0.7rem;
  color: var(--neon-cyan);
  background: transparent;
  border: 1px solid var(--neon-cyan);
  border-radius: 6px;
  width: 32px;
  height: 28px;
  cursor: pointer;
  padding: 0;
}

.ranking-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 180px;
  overflow-y: auto;
}

.ranking-list li {
  display: grid;
  grid-template-columns: 2rem 1fr auto;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.48rem;
  padding: 0.4rem 0.45rem;
  background: rgba(0, 240, 255, 0.06);
  border-radius: 6px;
  border: 1px solid rgba(0, 240, 255, 0.15);
}

.ranking-list li.top-1 {
  border-color: var(--neon-yellow);
  background: rgba(255, 230, 0, 0.1);
}

.ranking-list li.top-2 {
  border-color: #c0c0c0;
}

.ranking-list li.top-3 {
  border-color: #cd7f32;
}

.ranking-list li.me {
  box-shadow: inset 0 0 0 1px var(--neon-green);
}

.ranking-list .rank-pos {
  color: var(--neon-cyan);
}

.ranking-list .rank-name {
  color: #fff;
  letter-spacing: 0.12em;
}

.ranking-list .rank-pts {
  color: var(--neon-green);
}

.ranking-empty {
  display: block !important;
  text-align: center;
  opacity: 0.65;
  font-size: 0.42rem;
  line-height: 1.6;
  border: none !important;
  background: transparent !important;
}

.coin {
  color: var(--neon-pink);
  letter-spacing: 0.3em;
  animation: coin-blink 1.4s step-end infinite;
}

@keyframes coin-blink {
  50% { opacity: 0.3; }
}

@media (max-width: 520px) {
  .machine {
    width: 100%;
    max-width: 100%;
    border-radius: 18px;
    padding: 0.7rem 0.65rem 0.9rem;
    border-width: 3px;
    box-shadow:
      0 0 0 3px #0d0814,
      0 0 18px rgba(255, 45, 149, 0.28);
  }

  .cabinet-top {
    margin-bottom: 0.65rem;
  }

  .marquee {
    padding: 0.35rem 0;
    margin-bottom: 0.65rem;
  }

  .marquee-text {
    font-size: 0.48rem;
  }

  .logo-line {
    letter-spacing: 0.22em;
  }

  .screen {
    min-height: 0;
    padding: 1rem 0.7rem 1.1rem;
    gap: 0.75rem;
  }

  .welcome-msg {
    font-size: 0.58rem;
  }

  .prompt {
    font-size: 0.5rem;
  }

  .slot {
    width: min(22vw, 64px);
    height: min(24vw, 70px);
    font-size: clamp(1.2rem, 6vw, 1.55rem);
    min-width: 48px;
    min-height: 52px;
  }

  .hint {
    font-size: 0.38rem;
    max-width: 100%;
  }

  .arcade-btn {
    width: 100%;
    font-size: 0.62rem;
    padding: 0.95rem 1rem;
    min-height: 48px;
  }

  .arcade-btn.ghost {
    font-size: 0.45rem;
    min-height: 44px;
  }

  .game-card {
    padding: 0.9rem 0.75rem;
    gap: 0.2rem 0.55rem;
    min-height: 64px;
  }

  .game-icon {
    font-size: 1.55rem;
  }

  .game-name {
    font-size: 0.5rem;
  }

  .game-desc {
    font-size: 0.34rem;
  }

  .game-tag {
    display: none;
  }

  .player-tag {
    font-size: 0.48rem;
  }

  .ranking-panel {
    padding: 0.65rem 0.55rem 0.75rem;
  }

  .ranking-head h2 {
    font-size: 0.48rem;
  }

  .ranking-list {
    max-height: min(28vh, 160px);
  }

  .ranking-list li {
    font-size: 0.42rem;
    padding: 0.5rem 0.45rem;
    min-height: 36px;
  }

  .cabinet-foot {
    font-size: 0.34rem;
    gap: 0.35rem;
  }
}

@media (max-width: 360px) {
  .logo-main {
    font-size: 1.35rem;
  }

  .slot {
    width: 48px;
    height: 54px;
  }
}

@media (max-height: 700px) and (orientation: landscape) {
  body {
    justify-content: flex-start;
    padding-top: 0.4rem;
  }

  .machine {
    max-width: min(100%, 560px);
  }

  .screen {
    min-height: 0;
  }

  .ranking-list {
    max-height: 90px;
  }
}
