html, body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #1b2414;
  cursor: default;
}

canvas {
  display: block;
  width: 100vw;
  height: 100vh;
}

#start-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  place-items: center;
  padding: 18px;
  box-sizing: border-box;
  background: #7f9c56;
  color: var(--start-accent, #315a0b);
  cursor: default;
  overflow: hidden;
}

#start-screen.legacy-visible {
  display: grid;
}

#start-screen::before {
  content: "";
  position: absolute;
  inset: -12px;
  z-index: 0;
  background: var(
    --start-background-image,
    url("../assets/start-background.png")
  ) center / cover no-repeat;
  filter: none;
  transform: scale(1.02);
  animation: start-bg-pulse 16s ease-in-out infinite;
}

#start-screen.hidden {
  display: none;
}

#start-screen.cabinet-start {
  display: none;
}

.start-panel {
  position: relative;
  z-index: 1;
  width: min(380px, 100%);
  display: grid;
  justify-items: center;
  gap: 14px;
  transform: translateY(-2vh);
}

#start-form {
  width: 254px;
  display: grid;
  gap: 12px;
}

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

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

.room-select {
  width: 100%;
  height: 28px;
  border: 1px solid rgba(27, 36, 20, 0.86);
  border-radius: 4px;
  background: rgba(247, 247, 240, 0.72);
  color: #1f2b16;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  padding: 0 8px;
}

.unsupported-device {
  box-sizing: border-box;
  width: min(360px, calc(100vw - 36px));
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border: 2px solid #1b2414;
  border-radius: 6px;
  background: rgba(247, 247, 240, 0.78);
  color: #1f2b16;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  text-align: center;
  box-shadow: 0 3px 0 rgba(27, 36, 20, 0.72);
}

.unsupported-device.hidden {
  display: none;
}

.unsupported-device strong {
  color: var(--start-accent, #315a0b);
  font-size: 16px;
  line-height: 1.1;
}

.unsupported-device span {
  font-size: 13px;
  line-height: 1.35;
}

/* .tutorial-screen {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: #1b2414;
  color: #1f2b16;
  cursor: crosshair;
  overflow: hidden;
}

.tutorial-screen.hidden {
  display: none;
}

#tutorial-canvas {
  display: block;
  width: 100vw;
  height: 100vh;
}

.tutorial-exit {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 2;
  min-width: 92px;
  height: 34px;
  border: 2px solid #1b2414;
  border-radius: 6px;
  background: rgba(247, 247, 240, 0.78);
  color: #1f2b16;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 15px;
  letter-spacing: 0;
  cursor: pointer;
  box-shadow: 0 3px 0 rgba(27, 36, 20, 0.72);
}

.tutorial-popup {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 3;
  width: min(280px, calc(100vw - 36px));
  display: grid;
  gap: 16px;
  padding: 20px;
  border: 2px solid #1b2414;
  border-radius: 6px;
  background: rgba(247, 247, 240, 0.9);
  color: #1f2b16;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  text-align: center;
  transform: translate(-50%, -50%);
  box-shadow: 0 4px 0 rgba(27, 36, 20, 0.78);
}

.tutorial-popup.hidden {
  display: none;
}

.tutorial-popup strong {
  color: var(--start-accent, #315a0b);
  font-size: 24px;
  line-height: 1;
}

.tutorial-popup button {
  height: 36px;
  border: 2px solid #1b2414;
  border-radius: 6px;
  background: var(--start-accent, #315a0b);
  color: #fff;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 17px;
  letter-spacing: 0;
  cursor: pointer;
} */

.language-switch {
  width: 254px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.language-switch button {
  height: 24px;
  border: 1px solid rgba(27, 36, 20, 0.86);
  border-radius: 4px;
  background: rgba(247, 247, 240, 0.58);
  color: #1f2b16;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  letter-spacing: 0;
  cursor: pointer;
}

.language-switch button.active {
  background: var(--start-accent, #315a0b);
  color: #fff;
}

.skin-switch {
  width: 254px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.skin-switch button {
  height: 24px;
  border: 1px solid rgba(27, 36, 20, 0.86);
  border-radius: 4px;
  background: rgba(247, 247, 240, 0.58);
  color: #1f2b16;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  letter-spacing: 0;
  cursor: pointer;
}

.skin-switch button.active {
  background: var(--start-accent, #315a0b);
  color: #fff;
}

#start-version {
  justify-self: center;
  min-height: 16px;
  color: rgba(247, 247, 240, 0.86);
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1;
  text-shadow: 0 1px 2px rgba(27, 36, 20, 0.75);
}

#pilot-nick,
#pilot-password,
#pilot-password-repeat,
#start-form button {
  box-sizing: border-box;
  width: 100%;
  height: 36px;
  border: 2px solid #1b2414;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 18px;
  letter-spacing: 0;
}

#pilot-nick,
#pilot-password,
#pilot-password-repeat {
  padding: 0 10px;
  background: #f7f7f0;
  color: #1f2b16;
  outline: none;
}

#pilot-nick::placeholder,
#pilot-password::placeholder,
#pilot-password-repeat::placeholder {
  color: #9a9a9a;
}

#pilot-nick:focus,
#pilot-password:focus,
#pilot-password-repeat:focus {
  border-color: var(--start-accent, #315a0b);
}

#start-form button {
  background: var(--start-accent, #315a0b);
  color: #fff;
  cursor: pointer;
}

#start-form button:active {
  transform: translateY(1px);
}

.auth-panel {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 2px solid rgba(27, 36, 20, 0.82);
  border-radius: 6px;
  background: rgba(189, 208, 138, 0.82);
}

.nick-choice-panel {
  position: relative;
  display: grid;
  gap: 10px;
  padding: 14px 10px 10px;
  border: 2px solid rgba(27, 36, 20, 0.82);
  border-radius: 6px;
  background: rgba(189, 208, 138, 0.9);
}

.logged-in-panel {
  display: grid;
  gap: 10px;
  padding: 12px 10px;
  border: 2px solid rgba(27, 36, 20, 0.82);
  border-radius: 6px;
  background: rgba(189, 208, 138, 0.86);
}

.auth-panel.hidden,
.nick-choice-panel.hidden,
.logged-in-panel.hidden {
  display: none;
}

.auth-message,
.logged-in-message {
  min-height: 15px;
  color: #f7f7f0;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  line-height: 1.25;
  text-align: center;
  text-shadow: 0 1px 2px rgba(27, 36, 20, 0.75);
}

.auth-message {
  color: #1f2b16;
  text-shadow: none;
}

.logged-in-message {
  color: #1f2b16;
  font-size: 12px;
  text-shadow: none;
}

.auth-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.nick-choice-actions {
  display: grid;
  grid-template-columns: 1fr 1.35fr;
  gap: 8px;
}

#start-form .nick-choice-actions button {
  font-size: 12px;
}

#start-form .nick-choice-close {
  position: absolute;
  top: 3px;
  right: 4px;
  width: 22px;
  height: 22px;
  border: 0;
  background: transparent;
  color: #1f2b16;
  font-size: 20px;
  line-height: 1;
  padding: 0;
}

.pilot-dialog {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: grid;
  place-items: center;
  padding: 18px;
  box-sizing: border-box;
  background: rgba(27, 36, 20, 0.22);
  cursor: default;
}

.pilot-dialog.hidden {
  display: none;
}

.pilot-dialog-panel {
  position: relative;
  width: min(320px, calc(100vw - 36px));
  display: grid;
  gap: 10px;
  padding: 28px 16px 16px;
  border: 2px solid #1b2414;
  border-radius: 6px;
  background: rgba(189, 208, 138, 0.94);
  box-shadow: 0 4px 0 rgba(27, 36, 20, 0.72);
}

.pilot-dialog-close {
  position: absolute;
  top: 4px;
  right: 6px;
  width: 24px;
  height: 24px;
  border: 0;
  background: transparent;
  color: #1f2b16;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 18px;
  cursor: pointer;
}

#pilot-dialog-nick,
#pilot-dialog-password,
#pilot-dialog-password-repeat,
#pilot-dialog-back,
#pilot-dialog-confirm,
.pilot-dialog-confirm {
  box-sizing: border-box;
  width: 100%;
  height: 36px;
  border: 2px solid #1b2414;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 18px;
}

#pilot-dialog-nick,
#pilot-dialog-password,
#pilot-dialog-password-repeat {
  padding: 0 10px;
  background: #f7f7f0;
  color: #1f2b16;
  outline: none;
}

#pilot-dialog-password.hidden,
#pilot-dialog-password-repeat.hidden {
  display: none;
}

#pilot-dialog-confirm,
.pilot-dialog-confirm {
  background: #315a0b;
  color: #fff;
  cursor: pointer;
}

.pilot-dialog-actions {
  display: flex;
  gap: 8px;
}

#pilot-dialog-back {
  background: transparent;
  color: #1f2b16;
  cursor: pointer;
}

#pilot-dialog-back.hidden {
  display: none;
}

.pilot-dialog-message,
.cabinet-message-text {
  min-height: 15px;
  color: #1f2b16;
  font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  text-align: center;
}

.cabinet-message-text {
  font-size: 15px;
  line-height: 1.35;
}

#start-form .auth-logout {
  height: 26px;
  border-width: 1px;
  background: rgba(247, 247, 240, 0.68);
  color: #1f2b16;
  font-size: 12px;
}

@keyframes start-bg-pulse {
  0%,
  100% {
    transform: scale(1.02);
  }

  50% {
    transform: scale(1.08);
  }
}
