:root {
  color-scheme: dark;
  font-family: system-ui, "Segoe UI", sans-serif;
  background: #0d0d1a;
  color: #f0f0ff;
  --app-width: 100vw;
  --app-height: 100vh;
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0d0d1a;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  width: 100%;
  height: var(--app-height);
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  background: #0d0d1a;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

body.game-running {
  position: fixed;
  inset: 0;
  width: var(--app-width);
  height: var(--app-height);
  touch-action: none;
  user-select: none;
}

button,
input,
select {
  font: inherit;
}

.launcher {
  width: var(--app-width);
  height: var(--app-height);
  display: grid;
  place-items: center;
  overflow: auto;
  padding: max(16px, env(safe-area-inset-top)) 0 max(16px, env(safe-area-inset-bottom));
  background:
    linear-gradient(rgba(13, 13, 26, 0.15), rgba(13, 13, 26, 0.68)),
    url("./assets/images/tutorial/sky.png") center / cover,
    #12121f;
}

.launcher-inner {
  width: min(420px, calc(var(--app-width) - 32px));
  display: grid;
  gap: 14px;
  padding: 24px;
  max-height: calc(var(--app-height) - 32px);
  overflow: auto;
  background: rgba(18, 18, 31, 0.82);
  border: 1px solid rgba(160, 160, 210, 0.32);
  border-radius: 8px;
  text-align: right;
}

h1 {
  margin: 0 0 8px;
  color: #f2e680;
  font-size: clamp(1.6rem, 6vw, 2.25rem);
  line-height: 1.05;
  text-align: center;
}

.name-row {
  display: grid;
  gap: 6px;
  color: #b8c3e6;
}

input,
select {
  width: 100%;
  border: 1px solid rgba(170, 180, 230, 0.45);
  background: rgba(10, 10, 18, 0.78);
  color: #fff;
  border-radius: 6px;
  padding: 10px 12px;
  outline: none;
  text-align: inherit;
}

input[type="range"] {
  padding: 0;
  accent-color: #f2d86b;
}

input[dir="ltr"] {
  text-align: left;
}

input:disabled,
select:disabled {
  color: #9ca8cc;
  opacity: 0.68;
}

button {
  min-height: 44px;
  border: 1px solid rgba(170, 180, 230, 0.45);
  border-radius: 6px;
  color: #f0f0ff;
  background: #29293d;
  cursor: pointer;
}

button:hover {
  background: #3d3d5c;
}

button:active {
  background: #5c3885;
}

.download-button {
  min-height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(246, 222, 115, 0.72);
  border-radius: 6px;
  padding: 10px 12px;
  color: #18150a;
  background: #f2d86b;
  text-align: center;
  text-decoration: none;
  font-weight: 700;
}

.download-button:hover {
  background: #ffe58a;
}

.match-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  direction: ltr;
}

.icon-button {
  width: 46px;
  min-height: 46px;
  display: inline-grid;
  place-items: center;
  padding: 0;
}

.icon-button svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.whatsapp-button {
  color: #f4fff9;
  background: #137a5d;
}

.whatsapp-button:hover {
  background: #19936f;
}

.time-button {
  color: #fff9db;
  background: #4a3f8f;
}

.time-button:hover {
  background: #5b4fb0;
}

#status {
  min-height: 18px;
  margin: 0;
  color: #b2bfe6;
  text-align: center;
  font-size: 0.9rem;
}

#game {
  position: fixed;
  inset: 0;
  display: block;
  width: var(--app-width);
  height: var(--app-height);
  background: #0d0d1a;
  outline: none;
  touch-action: none;
}

.game-controls {
  position: fixed;
  top: max(62px, calc(env(safe-area-inset-top) + 10px));
  left: max(14px, env(safe-area-inset-left));
  z-index: 20;
  direction: ltr;
}

.game-volume-control {
  width: min(292px, calc(var(--app-width) - 28px));
  min-height: 42px;
  display: grid;
  grid-template-columns: 28px auto minmax(88px, 1fr) 28px 44px;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(170, 180, 230, 0.45);
  border-radius: 6px;
  background: rgba(18, 18, 31, 0.82);
  color: #f0f0ff;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
}

.game-volume-control span {
  color: #b8c3e6;
}

.game-volume-control input {
  min-width: 0;
  height: 20px;
  border: 0;
  background: transparent;
}

.game-volume-control output {
  color: #f2e680;
  text-align: right;
}

.volume-step-button {
  width: 28px;
  min-height: 28px;
  padding: 0;
  border-radius: 50%;
  font-size: 18px;
  line-height: 1;
  display: grid;
  place-items: center;
}

.touch-controls {
  display: none;
}

.touch-control-button {
  width: 66px;
  min-height: 66px;
  padding: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border-color: rgba(246, 222, 115, 0.64);
  color: #fff6c8;
  background: rgba(17, 18, 31, 0.74);
  box-shadow:
    0 10px 26px rgba(0, 0, 0, 0.38),
    inset 0 0 0 1px rgba(255, 255, 255, 0.08);
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  user-select: none;
}

.touch-control-button svg {
  width: 32px;
  height: 32px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.touch-control-button:hover {
  background: rgba(31, 33, 54, 0.78);
}

.touch-control-button:active,
.touch-control-button[aria-pressed="true"] {
  color: #18150a;
  background: rgba(242, 216, 107, 0.9);
  transform: translateY(2px);
}

.touch-fire-button {
  width: 74px;
  min-height: 74px;
  color: #ffd9d9;
  border-color: rgba(255, 132, 132, 0.72);
  background: rgba(72, 24, 32, 0.72);
}

.touch-fire-button:active,
.touch-fire-button[aria-pressed="true"] {
  color: #210909;
  background: rgba(255, 132, 132, 0.92);
}

@media (hover: none), (pointer: coarse), (max-width: 860px) {
  .touch-controls {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--app-width);
    height: var(--app-height);
    z-index: 30;
    display: block;
    direction: ltr;
    pointer-events: none;
    touch-action: none;
  }

  .touch-move-controls,
  .touch-fire-button,
  .touch-action-controls {
    position: absolute;
    pointer-events: auto;
  }

  .touch-move-controls {
    left: max(16px, env(safe-area-inset-left));
    bottom: max(18px, calc(env(safe-area-inset-bottom) + 18px));
    display: flex;
    gap: 14px;
  }

  .touch-fire-button {
    left: 50%;
    bottom: max(24px, calc(env(safe-area-inset-bottom) + 24px));
    transform: translateX(-50%);
  }

  .touch-fire-button:active,
  .touch-fire-button[aria-pressed="true"] {
    transform: translateX(-50%) translateY(2px);
  }

  .touch-action-controls {
    right: max(18px, env(safe-area-inset-right));
    bottom: max(18px, calc(env(safe-area-inset-bottom) + 18px));
    display: flex;
    flex-direction: column;
    gap: 12px;
  }
}

@media (max-width: 520px) {
  .game-controls {
    top: max(10px, env(safe-area-inset-top));
    left: max(10px, env(safe-area-inset-left));
  }

  .game-volume-control {
    width: min(236px, calc(var(--app-width) - 20px));
    grid-template-columns: 26px minmax(54px, 1fr) 26px 40px;
  }

  .game-volume-control span {
    display: none;
  }

  .touch-control-button {
    width: 58px;
    min-height: 58px;
  }

  .touch-control-button svg {
    width: 29px;
    height: 29px;
  }

  .touch-fire-button {
    width: 66px;
    min-height: 66px;
  }

  .touch-move-controls {
    gap: 10px;
  }

  .touch-action-controls {
    gap: 10px;
  }
}
