:root {
  color: #f4f7ff;
  background: #16191d;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  width: 100%;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-text-size-adjust: 100%;
}

body {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  overscroll-behavior: none;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  background:
    radial-gradient(circle at 20% 15%, rgba(78, 180, 142, 0.18), transparent 28rem),
    linear-gradient(180deg, #1c2026 0%, #101215 100%);
}

.app-shell {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  display: grid;
  place-items: center;
  overflow: hidden;
}

.online-root {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.start-screen {
  height: 100vh;
  height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 42%, rgba(11, 19, 32, 0.12), rgba(3, 7, 14, 0.82) 72%),
    linear-gradient(rgba(3, 7, 14, 0.1), rgba(3, 7, 14, 0.42)),
    url("../public/assets/sprites/start-background-energy-v1.png?v=start-bg-energy-v1") center / auto 100% no-repeat,
    linear-gradient(90deg, #020611 0%, #071527 48%, #020611 100%);
}

.start-panel {
  width: min(440px, 100%);
  padding: 22px;
  border: 1px solid rgba(126, 231, 255, 0.32);
  background: rgba(5, 10, 18, 0.78);
  box-shadow: 0 20px 52px rgba(0, 0, 0, 0.52);
  backdrop-filter: blur(2px);
}

.start-heading {
  display: grid;
  gap: 8px;
  margin-bottom: 18px;
  justify-items: center;
  text-align: center;
}

.start-kicker {
  color: #7ee7ff;
  font-size: 12px;
  font-weight: 700;
}

.start-heading h1 {
  margin: 0;
  color: #ffe65d;
  font-size: 34px;
  line-height: 1;
  letter-spacing: 0;
}

.start-heading strong {
  color: #eaf8ff;
  font-size: 13px;
}

.mode-choice {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}

.mode-choice button {
  min-height: 44px;
  border: 1px solid rgba(234, 248, 255, 0.24);
  background: rgba(20, 29, 38, 0.92);
  color: #f4f7ff;
  font: inherit;
  font-size: 16px;
  cursor: pointer;
}

.mode-choice button.is-selected {
  border-color: rgba(126, 231, 255, 0.76);
  background: rgba(101, 220, 255, 0.16);
}

.start-form {
  display: grid;
  gap: 12px;
}

.start-form.is-hidden {
  display: none;
}

.field {
  display: grid;
  gap: 6px;
}

.field span {
  color: #8fa4b5;
  font-size: 12px;
}

.field input,
.start-form button,
.voice-toggle,
#voiceStatus {
  min-height: 38px;
  border: 1px solid rgba(234, 248, 255, 0.24);
  background: rgba(20, 29, 38, 0.92);
  color: #f4f7ff;
  font: inherit;
  font-size: 16px;
}

.field input {
  width: 100%;
  padding: 0 10px;
  user-select: text;
  -webkit-user-select: text;
  touch-action: manipulation;
}

.primary-action {
  border-color: rgba(255, 230, 93, 0.52);
  background: rgba(255, 199, 90, 0.16);
}

.room-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
}

.start-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.start-form button,
.start-form button {
  padding: 0 12px;
  cursor: pointer;
}

.mode-choice button:hover,
.start-form button:hover {
  border-color: rgba(126, 231, 255, 0.76);
}

.start-form button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.start-note {
  margin: 2px 0 0;
  color: #8fa4b5;
  font-size: 12px;
  line-height: 1.55;
}

.game-screen {
  height: 100vh;
  height: 100dvh;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.game-screen.is-hidden,
.start-screen.is-hidden {
  display: none;
}

.game-panel {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
}

.online-shell {
  position: relative;
}

.online-toolbar {
  position: fixed;
  z-index: 2;
  top: max(10px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  max-width: calc(100vw - 20px);
  padding: 8px;
  border: 1px solid rgba(126, 231, 255, 0.32);
  background: rgba(8, 14, 22, 0.84);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.32);
}

.online-toolbar strong {
  min-width: 92px;
  color: #eaf8ff;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.online-toolbar input,
.online-toolbar button,
.voice-toggle,
#voiceStatus {
  height: 30px;
  border: 1px solid rgba(234, 248, 255, 0.24);
  background: rgba(20, 29, 38, 0.92);
  color: #f4f7ff;
  font: inherit;
  font-size: 12px;
}

.voice-toggle,
#voiceStatus {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  white-space: nowrap;
}

.voice-toggle input {
  width: 14px;
  height: 14px;
  padding: 0;
  margin: 0;
  accent-color: #65dcff;
}

#voiceStatus {
  color: #8fa4b5;
}

.online-toolbar input {
  width: 92px;
  padding: 0 8px;
}

#roomInput {
  text-transform: uppercase;
}

.online-toolbar button {
  padding: 0 12px;
  cursor: pointer;
}

.online-toolbar button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.online-toolbar button:hover {
  border-color: rgba(126, 231, 255, 0.76);
}

canvas {
  width: min(100vw, calc(100dvh * 9 / 16));
  max-width: 100vw;
  max-height: 100dvh;
  aspect-ratio: 9 / 16;
  height: auto;
  border: 0;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #202832;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.44);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

@media (max-width: 520px) {
  .start-screen {
    padding: 14px;
  }

  .start-panel {
    padding: 16px;
  }

  .start-heading h1 {
    font-size: 29px;
  }

  .room-grid {
    grid-template-columns: 1fr;
  }

  .mode-choice {
    grid-template-columns: 1fr;
  }

  .online-toolbar {
    top: max(6px, env(safe-area-inset-top));
    gap: 5px;
    padding: 6px;
  }

  .online-toolbar strong {
    min-width: 72px;
    font-size: 10px;
  }

  .online-toolbar input {
    width: 68px;
  }

  .online-toolbar button {
    padding: 0 6px;
    font-size: 10px;
  }

  .voice-toggle,
  #voiceStatus {
    height: 28px;
    padding: 0 6px;
    font-size: 10px;
  }
}
