:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  background: #10051c;
  color: #fff;
  --neon-violet: #19072b;
  --neon-magenta: #ff2bd6;
  --neon-cyan: #52f7ff;
  --neon-yellow: #ffe55c;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-width: 320px;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

button,
canvas {
  touch-action: manipulation;
}

#game-shell {
  display: grid;
  grid-template-rows: 96px minmax(0, 1fr) 104px;
  width: 100%;
  min-height: 100%;
  height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 22%, rgb(90 20 119 / 42%), transparent 43%),
    #10051c;
}

#approved-hud {
  z-index: 4;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.4rem;
  min-width: 0;
  padding: 0.5rem 0.65rem;
  background: linear-gradient(180deg, rgb(10 8 21 / 98%), rgb(12 5 25 / 86%));
}

.hud-cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  padding: 0.45rem 0.65rem;
  border: 1px solid rgb(82 247 255 / 40%);
  border-radius: 0.65rem;
  background: rgb(7 8 18 / 88%);
  box-shadow: inset 0 0 18px rgb(82 247 255 / 5%);
  color: var(--neon-cyan);
  font-size: 0.66rem;
  font-weight: 900;
  letter-spacing: 0.1em;
}

.hud-cell output {
  overflow: hidden;
  color: #fff;
  font: 950 1rem ui-monospace, SFMono-Regular, monospace;
  text-overflow: ellipsis;
  text-shadow: 0 0 10px currentColor;
}

.hud-jackpot,
.hud-bet {
  border-color: rgb(255 229 92 / 48%);
  color: var(--neon-yellow);
}

.hud-combo {
  border-color: rgb(255 43 214 / 48%);
  color: var(--neon-magenta);
}

#machine-stage {
  position: relative;
  z-index: 1;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

#sound-button {
  position: absolute;
  z-index: 6;
  top: 0.65rem;
  right: max(0.65rem, env(safe-area-inset-right));
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid rgb(82 247 255 / 72%);
  border-radius: 50%;
  background: linear-gradient(145deg, rgb(40 18 59 / 94%), rgb(13 8 27 / 96%));
  color: var(--neon-cyan);
  font: inherit;
  font-size: 1.25rem;
  line-height: 1;
  box-shadow: inset 0 0 14px rgb(82 247 255 / 10%), 0 0 16px rgb(82 247 255 / 28%);
  cursor: pointer;
}

#language-control {
  position: absolute;
  z-index: 6;
  top: 0.65rem;
  right: max(4.25rem, calc(env(safe-area-inset-right) + 3.6rem));
  width: 132px;
}

#language-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 132px;
  height: 48px;
  padding: 0 0.85rem 0 1rem;
  border: 1px solid rgb(255 43 214 / 72%);
  border-radius: 999px;
  background: linear-gradient(145deg, rgb(40 18 59 / 96%), rgb(13 8 27 / 98%));
  color: #fff;
  font: 850 0.8rem Inter, ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0.03em;
  box-shadow: inset 0 0 14px rgb(255 43 214 / 9%), 0 0 16px rgb(255 43 214 / 24%);
  text-shadow: 0 0 8px rgb(255 255 255 / 34%);
  cursor: pointer;
}

#language-button[aria-expanded="true"] {
  border-color: var(--neon-cyan);
  box-shadow: inset 0 0 16px rgb(82 247 255 / 10%), 0 0 20px rgb(82 247 255 / 32%);
}

.language-arrow {
  color: var(--neon-magenta);
  font-size: 1.1rem;
  transition: transform 140ms ease;
}

#language-button[aria-expanded="true"] .language-arrow {
  transform: rotate(180deg);
}

#language-menu {
  position: absolute;
  top: 56px;
  right: 0;
  display: grid;
  gap: 0.3rem;
  width: 176px;
  padding: 0.45rem;
  border: 1px solid rgb(82 247 255 / 60%);
  border-radius: 1rem;
  background: #160822;
  box-shadow: 0 12px 36px rgb(0 0 0 / 70%), 0 0 24px rgb(82 247 255 / 20%);
}

#language-menu[hidden] {
  display: none;
}

.language-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 44px;
  padding: 0.65rem 0.75rem;
  border: 1px solid transparent;
  border-radius: 0.7rem;
  background: rgb(255 255 255 / 4%);
  color: #fff;
  font: 800 0.88rem Inter, ui-sans-serif, system-ui, sans-serif;
  text-align: left;
  cursor: pointer;
}

.language-option small {
  color: rgb(255 255 255 / 58%);
  font-size: 0.65rem;
  letter-spacing: 0.12em;
}

.language-option:hover,
.language-option:focus-visible {
  border-color: rgb(82 247 255 / 55%);
  background: rgb(82 247 255 / 10%);
  outline: none;
}

.language-option[aria-selected="true"] {
  border-color: rgb(255 43 214 / 78%);
  background: linear-gradient(90deg, rgb(255 43 214 / 20%), rgb(82 247 255 / 8%));
  box-shadow: inset 0 0 16px rgb(255 43 214 / 10%);
}

#language-button:focus-visible {
  outline: 3px solid var(--neon-yellow);
  outline-offset: 3px;
}

#sound-button[aria-pressed="true"] {
  border-color: rgb(255 255 255 / 36%);
  color: rgb(255 255 255 / 62%);
  box-shadow: inset 0 0 12px rgb(0 0 0 / 28%), 0 0 10px rgb(255 255 255 / 10%);
}

#sound-button:active {
  transform: scale(0.96);
}

#sound-button:focus-visible {
  outline: 3px solid var(--neon-yellow);
  outline-offset: 3px;
}

#game-controls {
  z-index: 3;
  display: grid;
  grid-template-columns: 70px minmax(80px, 1fr) 70px;
  gap: 0.6rem;
  align-items: center;
  min-width: 0;
  min-height: 104px;
  padding: 0.55rem max(0.7rem, env(safe-area-inset-right))
    max(0.55rem, env(safe-area-inset-bottom)) max(0.7rem, env(safe-area-inset-left));
  border-top: 1px solid rgb(82 247 255 / 48%);
  background: linear-gradient(180deg, rgb(27 10 43 / 94%), rgb(10 3 20 / 98%));
  box-shadow: 0 -10px 32px rgb(255 43 214 / 14%);
  backdrop-filter: blur(12px);
}

#game-controls button {
  min-width: 44px;
  min-height: 3.5rem;
  border: 2px solid currentColor;
  border-radius: 1rem;
  background: linear-gradient(180deg, #47205e, #241033);
  font: inherit;
  font-weight: 800;
  letter-spacing: 0.08em;
  box-shadow: inset 0 0 16px rgb(255 255 255 / 7%), 0 0 14px currentColor;
  text-shadow: 0 0 8px currentColor;
  cursor: pointer;
}

#game-controls #bet-button {
  color: var(--neon-yellow);
}

#game-controls .primary-spin {
  width: min(78px, 20vw);
  min-width: 68px;
  height: auto;
  aspect-ratio: 1;
  justify-self: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #ff32c7, #652dff);
  color: #fff;
  box-shadow: inset 0 0 20px rgb(255 255 255 / 16%), 0 0 28px rgb(232 46 255 / 60%);
}

#game-controls #auto-button {
  color: var(--neon-magenta);
}

#game-controls button:active {
  transform: translateY(1px) scale(0.99);
}

#game-controls button:focus-visible {
  outline: 3px solid #52f7ff;
  outline-offset: 3px;
}

.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;
}

@media (min-width: 700px) {
  #game-shell {
    grid-template-rows: 76px minmax(0, 1fr) 104px;
  }

  #approved-hud {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
    padding: 0.75rem max(1.5rem, env(safe-area-inset-right)) 0.5rem
      max(1.5rem, env(safe-area-inset-left));
  }

  .hud-cell {
    padding: 0.55rem 0.85rem;
    font-size: 0.72rem;
  }

  .hud-cell output {
    font-size: 1.12rem;
  }

  #game-controls {
    grid-template-columns: minmax(8rem, 12rem) 84px minmax(8rem, 12rem);
    justify-content: center;
    gap: 1rem;
    padding: 1rem max(1.5rem, env(safe-area-inset-right))
      max(1rem, env(safe-area-inset-bottom)) max(1.5rem, env(safe-area-inset-left));
  }

  #game-controls button:not(.primary-spin) {
    min-height: 3.5rem;
    font-size: 1.05rem;
    border-radius: 999px;
  }

  #game-controls .primary-spin {
    width: 82px;
  }

  #sound-button {
    top: 0.85rem;
    right: max(1.25rem, env(safe-area-inset-right));
  }

  #language-control {
    top: 0.85rem;
    right: max(5rem, calc(env(safe-area-inset-right) + 3.75rem));
  }
}

@media (min-width: 1100px) {
  #approved-hud {
    width: min(960px, 100%);
    margin-inline: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  #game-controls button {
    transition: none;
  }
}
