:root {
  --bgDefault: #0f0f0f;
  --fgDefault: rgba(255, 255, 255, 0.87);
  --fgMuted: rgba(255, 255, 255, 0.5);
  --borderDefault: rgba(255, 255, 255, 0.1);
  --btnBg: rgba(25, 31, 27, 0.3);
  --btnBgHover: rgba(38, 44, 40, 0.8);
  --focusOutline: #58a6ff;

  --fontFamily:
    "Mona Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica,
    Arial, sans-serif;
}

body {
  margin: 0;
  padding: 0;
  color: var(--fgDefault);
  background-color: var(--bgDefault);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Skip link for keyboard accessibility */
.skip-link {
  position: absolute;
  top: -100px;
  left: 0;
  background: var(--bgDefault);
  color: var(--fgDefault);
  padding: 16px 24px;
  z-index: 10000;
  text-decoration: none;
  border-radius: 4px;
  border: 2px solid var(--fgDefault);
  font-family: var(--fontFamily);
  font-weight: 600;
}

.skip-link:focus {
  top: 0;
}

/* Header */
header {
  background: linear-gradient(
    180deg,
    rgba(15, 15, 15, 0.95) 0%,
    rgba(15, 15, 15, 0.8) 100%
  );
  border-bottom: 1px solid var(--borderDefault);
  display: grid;
  place-items: center;
}

header .logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  color: var(--fgDefault);
}

header .logo svg {
  fill: #fff;
  width: 36px;
  height: 36px;
}

header .logo h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 550;
  font-family: var(--fontFamily);
  letter-spacing: -0.01em;
}

.header-container {
  width: 100%;
  max-width: 1024px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 20px;
}

.logo-container {
  display: flex;
  align-items: center;
  justify-content: center;
  border-inline-end: var(--borderDefault) 2px solid;
  padding: 12px;
}

/* Footer */
footer {
  padding: 16px;
  text-align: center;
  font-size: 12px;
  color: var(--fgMuted);
  font-family: var(--fontFamily);
}

footer p {
  margin: 0;
}

#app {
  width: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  box-sizing: border-box;
}

#game-wrapper {
  width: 100%;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 1024px;
}

#game-container {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 8px;
  overflow: hidden;
}

html[data-cinema-mode] #app {
  padding-inline: 0;
}

html[data-cinema-mode] #game-wrapper {
  max-width: none;
}

html[data-cinema-mode] #game-container {
  border-radius: 0;
}

#game-container:focus {
  outline: none;
}

#game-container:focus-visible {
  outline: 3px solid var(--focus-outline);
  outline-offset: 2px;
}

.display-btn {
  all: unset;
  width: 36px;
  height: 36px;
  background-color: var(--btnBg);
  backdrop-filter: blur(8px);
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  bottom: 16px;
  right: 16px;
  z-index: 2;
}

.display-btn[hidden] {
  display: none !important;
}

.display-btn:hover {
  background-color: var(--btnBgHover);
}

.display-btn:focus-visible {
  outline: 2px solid var(--focusOutline);
  outline-offset: 2px;
}

.display-btn img {
  width: 16px;
  height: 16px;
  filter: invert(1);
}

.display-btn::before,
.display-btn::after {
  opacity: 0;
  pointer-events: none;
  position: absolute;
  transition:
    opacity 0.16s ease,
    transform 0.16s ease;
}

.display-btn::before {
  content: attr(data-tooltip);
  right: 0;
  bottom: calc(100% + 12px);
  max-width: calc(100vw - 32px);
  padding: 8px 10px;
  color: #0f0f0f;
  background: rgba(255, 255, 255, 0.96);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  font-family: var(--fontFamily);
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  transform: translateY(4px);
}

.display-btn::after {
  content: "";
  right: 22px;
  bottom: calc(100% + 4px);
  border: 5px solid transparent;
  border-top-color: rgba(255, 255, 255, 0.96);
  transform: translateY(4px);
}

.display-btn:hover::before,
.display-btn:hover::after,
.display-btn:focus-visible::before,
.display-btn:focus-visible::after {
  opacity: 1;
  transform: translateY(0);
}

#fullscreen-btn {
  right: 16px;
}

#cinema-btn {
  right: 58px;
}

html[data-layout="embed"],
html[data-layout="embed"] body {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  overflow: hidden;
}

html[data-layout="embed"] body {
  position: fixed;
}

html[data-layout="embed"] header,
html[data-layout="embed"] footer {
  display: none;
}

html[data-layout="embed"] main,
html[data-layout="embed"] #app,
html[data-layout="embed"] #game-wrapper {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  overflow: hidden;
}

html[data-layout="embed"] #app {
  padding: 0;
  justify-content: center;
}

html[data-layout="embed"] #game-wrapper {
  max-width: none;
}

html[data-layout="embed"] #game-container {
  width: 100%;
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  aspect-ratio: unset;
  border-radius: 0;
}

html[data-layout="embed"] #game-container canvas {
  max-height: 100vh !important;
  max-height: 100dvh !important;
  object-fit: contain;
}

@media (max-width: 720px) {
  .header-container {
    padding: 0 16px;
  }
}

/* Mobile specific styles */
@media (pointer: coarse) {
  main {
    padding-top: 0;
  }

  html:not([data-layout="embed"]) #fullscreen-btn,
  html:not([data-layout="embed"]) #cinema-btn {
    display: none !important;
  }
}

/* Mobile landscape - make game fullscreen */
@media (pointer: coarse) and (orientation: landscape) {
  footer {
    display: none !important;
  }

  header {
    position: fixed;
    top: calc(env(safe-area-inset-top) + 8px);
    right: calc(env(safe-area-inset-right) + 8px);
    left: auto;
    width: auto;
    z-index: 10002;
    background: transparent;
    border-bottom: 0;
    display: block;
    pointer-events: none;
  }

  .header-container {
    width: auto;
    max-width: none;
    padding: 0;
    gap: 0;
    justify-content: flex-end;
    pointer-events: none;
  }

  .skip-link,
  header .logo {
    display: none !important;
  }

  /* Make body fill screen with no scroll */
  html,
  body {
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    position: fixed;
    width: 100%;
  }

  main {
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
  }

  #app {
    padding: 0;
    height: 100dvh;
    max-height: 100dvh;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
    box-sizing: border-box;
  }

  #game-wrapper {
    max-width: none;
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
  }

  #game-container {
    width: 100%;
    height: 100dvh !important;
    max-height: 100dvh !important;
    aspect-ratio: unset;
    border-radius: 0;
  }

  #game-container canvas {
    max-height: 100dvh !important;
    object-fit: contain;
  }
}
