:root {
  --green-950: #032719;
  --green-900: #063f26;
  --green-800: #075536;
  --green-700: #0d6b43;
  --green-600: #238052;
  --green-500: #63a04c;
  --yellow: #f2b51d;
  --yellow-soft: #ffd95c;
  --button-green: #89ad59;
  --white: #ffffff;
  --ink: #102017;
  --muted: rgba(255, 255, 255, 0.76);
  --line: rgba(255, 255, 255, 0.22);
  --shadow: 0 24px 68px rgba(0, 0, 0, 0.34);
  --pad-x: clamp(18px, 5vw, 76px);
  --pad-y: clamp(18px, 4dvh, 62px);
  --stadium-height: clamp(230px, 52.2vw, 620px);
  --stadium-safe-bottom: clamp(104px, calc(var(--stadium-height) * 0.32), 230px);
}

@font-face {
  font-family: "Montserrat";
  src: url("fonts/Montserrat-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Montserrat";
  src: url("fonts/Montserrat-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Montserrat";
  src: url("fonts/Montserrat-ExtraBold.ttf") format("truetype");
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--green-950);
  color: var(--white);
  font-family: Montserrat, Arial, Helvetica, sans-serif;
  letter-spacing: 0;
}

body {
  min-width: 320px;
  min-height: 100vh;
  min-height: 100dvh;
  touch-action: manipulation;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

img,
video {
  max-width: 100%;
  display: block;
}

.stage_frame {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--green-950);
}

.stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  isolation: isolate;
  background: var(--green-950);
}

.screen {
  position: absolute;
  inset: 0;
  min-width: 0;
  min-height: 0;
  padding:
    max(env(safe-area-inset-top), var(--pad-y))
    max(env(safe-area-inset-right), var(--pad-x))
    max(env(safe-area-inset-bottom), var(--stadium-safe-bottom))
    max(env(safe-area-inset-left), var(--pad-x));
  display: grid;
  opacity: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
  transition: opacity 340ms ease;
}

.screen.active {
  opacity: 1;
  z-index: 2;
  pointer-events: auto;
}

.screen > * {
  position: relative;
  z-index: 2;
}

.screen_dark,
.screen_idle {
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.02), rgba(0, 0, 0, 0.08)),
    url("img/nestle-journey-bg.png") center / cover no-repeat,
    var(--green-800);
}

.screen_dark::before,
.screen_idle::before,
.screen_dark::after,
.screen_idle::after {
  content: "";
  position: absolute;
  pointer-events: none;
  z-index: 0;
}

.screen_dark::before,
.screen_idle::before {
  inset: 0;
  background:
    radial-gradient(ellipse at center 48%, rgba(147, 183, 105, 0.18), transparent 42%),
    linear-gradient(180deg, rgba(0, 0, 0, 0), rgba(3, 39, 25, 0.12));
  opacity: 0.9;
}

.screen_dark::after,
.screen_idle::after {
  inset: auto 0 0;
  height: var(--stadium-height);
  background: url("img/nestle-journey-stadium.png") center bottom / cover no-repeat;
  opacity: 1;
}

h1,
p {
  margin: 0;
}

h1 {
  max-width: 15ch;
  color: var(--white);
  font-size: clamp(38px, 7.4vmin, 86px);
  line-height: 1.02;
  font-weight: 800;
  text-align: center;
}

.eyebrow {
  margin: 0;
  color: var(--yellow-soft);
  font-size: clamp(13px, 2.1vmin, 30px);
  line-height: 1;
  font-weight: 800;
  text-transform: uppercase;
}

.brand_row {
  grid-area: brand;
  width: min(100%, 780px);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: clamp(28px, 9vw, 190px);
  justify-self: center;
  align-self: start;
}

.brand_logo {
  width: clamp(156px, 24vmin, 300px);
  height: auto;
}

.brand_trophy {
  width: clamp(104px, 16vmin, 188px);
  height: auto;
  margin-top: clamp(-4px, -0.3vmin, 0px);
}

.screen_idle {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(220px, 35.5dvh) auto minmax(0, 1fr);
  grid-template-areas:
    "idle-mark"
    "content"
    ".";
  row-gap: clamp(8px, 1.4dvh, 22px);
  justify-items: center;
  text-align: center;
}

.idle_mark {
  grid-area: idle-mark;
  width: min(86vw, 680px);
  align-self: end;
  justify-self: center;
  display: grid;
  place-items: center;
  margin-bottom: clamp(12px, 2dvh, 34px);
}

.idle_trophy {
  width: min(74vw, 640px);
  height: auto;
  filter: drop-shadow(0 18px 24px rgba(0, 0, 0, 0.2));
}

.idle_player_silhouette {
  position: absolute;
  left: 50%;
  bottom: clamp(18px, 2.1dvh, 42px);
  z-index: 1;
  width: min(52vw, 560px);
  max-height: 43dvh;
  transform: translateX(-50%);
  filter: drop-shadow(0 22px 20px rgba(0, 0, 0, 0.28));
  pointer-events: none;
}

.idle_hashtags {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(env(safe-area-inset-bottom), clamp(8px, 1.2dvh, 20px));
  z-index: 3;
  color: rgba(255, 255, 255, 0.9);
  font-size: clamp(7px, 1.15vmin, 13px);
  line-height: 1;
  font-weight: 800;
  text-align: center;
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.35);
}

.settings_button {
  position: absolute;
  right: max(12px, env(safe-area-inset-right));
  top: max(12px, env(safe-area-inset-top));
  z-index: 6;
  width: clamp(42px, 5.4vmin, 62px);
  height: clamp(42px, 5.4vmin, 62px);
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  opacity: 0.14;
  transition: opacity 180ms ease, background 180ms ease, transform 180ms ease;
}

.settings_button span {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
}

.settings_button::before,
.settings_button::after {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.settings_button::before {
  width: 46%;
  height: 46%;
  border: 4px solid rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  box-shadow:
    0 -13px 0 -7px rgba(255, 255, 255, 0.92),
    0 13px 0 -7px rgba(255, 255, 255, 0.92),
    13px 0 0 -7px rgba(255, 255, 255, 0.92),
    -13px 0 0 -7px rgba(255, 255, 255, 0.92),
    9px 9px 0 -7px rgba(255, 255, 255, 0.92),
    -9px 9px 0 -7px rgba(255, 255, 255, 0.92),
    9px -9px 0 -7px rgba(255, 255, 255, 0.92),
    -9px -9px 0 -7px rgba(255, 255, 255, 0.92);
}

.settings_button::after {
  width: 14%;
  height: 14%;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
}

.settings_button:hover,
.settings_button:focus-visible {
  opacity: 0.86;
  background: rgba(255, 255, 255, 0.16);
  outline: none;
  transform: scale(1.03);
}

.screen_idle .settings_button {
  opacity: 0.025;
}

.idle_content {
  grid-area: content;
  width: min(100%, 940px);
  display: grid;
  align-content: start;
  justify-items: center;
  justify-self: center;
  align-self: start;
  text-align: center;
  z-index: 4;
}

.primary_button,
.ghost_button {
  min-width: 0;
  min-height: clamp(50px, 6.6dvh, 82px);
  border: 0;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 clamp(22px, 4vw, 46px);
  font-size: clamp(17px, 2.7vmin, 30px);
  line-height: 1.05;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
  white-space: normal;
}

.primary_button {
  background: var(--yellow);
  color: #ffffff;
  box-shadow: 0 18px 42px rgba(0, 0, 0, 0.2);
}

.ghost_button {
  background: var(--button-green);
  color: #ffffff;
  border: 0;
}

.primary_button:disabled,
.ghost_button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.idle_content .primary_button {
  width: min(100%, 900px);
}

.idle_choice_button {
  min-height: clamp(150px, 19dvh, 280px);
  border-radius: 999px;
  display: flex;
  flex-direction: column;
  padding: clamp(24px, 4dvh, 48px) clamp(34px, 7vw, 90px);
  background: #f3ad3b;
  color: #ffffff;
  box-shadow: none;
  font-size: clamp(38px, 6.7vmin, 82px);
  line-height: 1.22;
  font-weight: 800;
  text-transform: uppercase;
  text-shadow: none;
}

.idle_choice_button span {
  display: block;
}

.screen_dark {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas:
    "brand"
    "content";
  row-gap: clamp(14px, 3dvh, 36px);
}

.screen[data-screen="name"] {
  padding-top: max(env(safe-area-inset-top), clamp(14px, 3dvh, 42px));
  row-gap: clamp(12px, 3dvh, 42px);
}

.name_panel,
.camera_panel,
.confirm_panel,
.processing_panel,
.error_panel {
  grid-area: content;
  width: min(100%, 860px);
  justify-self: center;
  align-self: center;
}

.name_panel {
  display: grid;
  gap: clamp(12px, 2.1dvh, 24px);
  justify-items: stretch;
  align-content: center;
  text-align: center;
}

.screen[data-screen="name"] .name_panel {
  align-self: start;
  width: min(100%, 760px);
  gap: clamp(10px, 1.8dvh, 20px);
}

.name_panel h1 {
  max-width: none;
  justify-self: center;
  font-size: clamp(34px, 6.4vmin, 62px);
  line-height: 1;
  text-transform: uppercase;
}

.name_panel label {
  color: var(--muted);
  font-size: clamp(13px, 1.9vmin, 22px);
  font-weight: 800;
}

.name_panel input {
  width: 100%;
  min-height: clamp(58px, 7.4dvh, 90px);
  border: 3px solid var(--yellow);
  border-radius: 8px;
  padding: 0 clamp(18px, 3vw, 34px);
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  outline: none;
  font-size: clamp(22px, 3.7vmin, 40px);
  font-weight: 800;
  text-transform: uppercase;
}

.name_panel input:focus {
  border-color: var(--yellow);
}

.name_panel .primary_button {
  width: 100%;
}

.virtual_keyboard {
  width: 100%;
  display: grid;
  gap: clamp(6px, 1vmin, 10px);
  padding: clamp(8px, 1.3vmin, 14px);
  border-radius: 8px;
  background: rgba(3, 39, 25, 0.24);
  border: 2px solid rgba(255, 255, 255, 0.20);
}

.keyboard_row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: clamp(5px, 0.8vmin, 9px);
}

.keyboard_row_actions {
  grid-auto-flow: initial;
  grid-auto-columns: initial;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 2fr) minmax(0, 1.1fr);
}

.keyboard_key {
  min-width: 0;
  min-height: clamp(42px, 6.4dvh, 78px);
  border: 0;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 clamp(6px, 1vw, 12px);
  background: rgba(255, 255, 255, 0.92);
  color: var(--green-900);
  font-size: clamp(16px, 2.45vmin, 28px);
  line-height: 1;
  font-weight: 800;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.16);
}

.keyboard_key:active {
  transform: translateY(1px);
  background: var(--yellow-soft);
}

.keyboard_key.wide {
  min-width: 0;
}

.keyboard_key.space {
  min-width: 0;
}

.keyboard_key.action {
  background: rgba(242, 181, 29, 0.96);
  color: #3f2b08;
  font-size: clamp(13px, 2.2vmin, 26px);
}

.camera_panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "copy"
    "view"
    "actions"
    "file";
  gap: clamp(12px, 2.4vmin, 28px);
  align-items: center;
  justify-items: center;
}

.camera_head {
  grid-area: copy;
  display: grid;
  gap: clamp(8px, 1.5vmin, 16px);
  justify-items: center;
  text-align: center;
}

.camera_head h1,
.confirm_copy h1 {
  max-width: 13ch;
  font-size: clamp(36px, 6.6vmin, 70px);
}

.camera_head p:not(.eyebrow),
.confirm_copy p:not(.eyebrow),
.processing_panel p:not(.eyebrow),
.result_copy p {
  color: var(--muted);
  font-size: clamp(15px, 2.35vmin, 30px);
  line-height: 1.24;
  font-weight: 700;
}

.camera_view {
  grid-area: view;
  position: relative;
  width: min(52vw, 34dvh, 430px);
  aspect-ratio: 3 / 4;
  justify-self: center;
  overflow: hidden;
  border: clamp(6px, 1.1vmin, 12px) solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.10);
  box-shadow: var(--shadow);
}

.camera_view video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transform: scaleX(-1);
}

.capture_countdown {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  color: #ffffff;
  font-size: clamp(110px, 22vmin, 260px);
  line-height: 0.82;
  font-weight: 900;
  text-shadow:
    0 10px 34px rgba(0, 0, 0, 0.58),
    0 0 0.08em rgba(242, 181, 29, 0.9);
  background:
    radial-gradient(circle at center, rgba(242, 181, 29, 0.22), transparent 34%),
    rgba(0, 0, 0, 0.18);
  pointer-events: none;
  animation: countdownpop 0.92s ease-in-out both;
}

.camera_fallback {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: clamp(10px, 2vmin, 16px);
  padding: clamp(24px, 5vmin, 52px);
  background: rgba(3, 39, 25, 0.94);
  text-align: center;
}

.camera_fallback strong {
  color: var(--yellow-soft);
  font-size: clamp(22px, 4vmin, 42px);
  line-height: 1;
}

.camera_fallback span {
  max-width: 24ch;
  color: var(--muted);
  font-size: clamp(14px, 2.4vmin, 28px);
  line-height: 1.25;
  font-weight: 700;
}

.camera_actions {
  grid-area: actions;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(10px, 2vmin, 24px);
  width: min(100%, 580px);
}

.file_fallback {
  grid-area: file;
  width: 100%;
  min-height: clamp(42px, 5.5dvh, 72px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.84);
  font-size: clamp(14px, 2vmin, 24px);
  font-weight: 800;
}

.file_fallback input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.confirm_panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "copy"
    "preview"
    "actions";
  gap: clamp(14px, 2.8vmin, 32px);
  align-items: center;
  justify-items: center;
}

.confirm_copy {
  grid-area: copy;
  display: grid;
  gap: clamp(12px, 2vmin, 22px);
  justify-items: center;
  text-align: center;
}

.captured_preview {
  grid-area: preview;
  width: min(52vw, 32dvh, 430px);
  aspect-ratio: 3 / 4;
  justify-self: center;
  object-fit: cover;
  border: clamp(6px, 1.1vmin, 12px) solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.12);
  box-shadow: var(--shadow);
}

.confirm_actions {
  grid-area: actions;
  width: min(100%, 580px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: clamp(10px, 2vmin, 24px);
}

.processing_panel {
  max-width: 880px;
  display: grid;
  justify-items: center;
  gap: clamp(16px, 3dvh, 28px);
  text-align: center;
}

.processing_panel h1 {
  max-width: 12ch;
  font-size: clamp(38px, 6.8vmin, 76px);
}

.loader_line {
  position: relative;
  width: min(100%, 680px);
  height: clamp(14px, 2.2vmin, 24px);
  margin-top: clamp(12px, 4dvh, 42px);
  overflow: hidden;
  border-radius: 999px;
  background:
    repeating-linear-gradient(
      115deg,
      rgba(255, 255, 255, 0.10) 0 14px,
      rgba(255, 255, 255, 0.28) 14px 24px,
      rgba(255, 255, 255, 0.10) 24px 38px
    ),
    rgba(255, 255, 255, 0.18);
  background-size: 86px 100%;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.10),
    0 0 32px rgba(242, 181, 29, 0.12);
  animation: loadertrack 0.65s linear infinite;
}

.loader_line::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background:
    repeating-linear-gradient(
      115deg,
      rgba(255, 255, 255, 0.00) 0 20px,
      rgba(255, 255, 255, 0.28) 20px 31px,
      rgba(255, 255, 255, 0.00) 31px 48px
    ),
    linear-gradient(
      90deg,
      transparent 0 11%,
      rgba(242, 181, 29, 0.28) 18%,
      rgba(242, 181, 29, 0.98) 30%,
      rgba(255, 217, 92, 1) 42%,
      rgba(242, 181, 29, 0.98) 54%,
      rgba(242, 181, 29, 0.28) 66%,
      transparent 76% 100%
    );
  background-size: 96px 100%, 220% 100%;
  background-position: 0 0, 0 0;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.08),
    0 0 30px rgba(242, 181, 29, 0.48);
  animation: loaderfill 1.1s linear infinite, loaderpulse 1.1s ease-in-out infinite;
}

.loader_line::after {
  content: "";
  position: absolute;
  inset-block: -60%;
  left: -35%;
  width: 28%;
  border-radius: inherit;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.72), transparent);
  filter: blur(1px);
  transform: skewX(-18deg);
  animation: loadershine 1.35s linear infinite;
  mix-blend-mode: screen;
  pointer-events: none;
}

.result_layout {
  grid-area: content;
  width: min(100%, 880px);
  min-height: 0;
  justify-self: center;
  align-self: center;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(14px, 2.6vmin, 28px);
  align-items: center;
  justify-items: center;
}

.result_copy {
  display: grid;
  gap: clamp(10px, 1.8vmin, 20px);
  align-content: center;
  justify-items: center;
  text-align: center;
}

.result_copy h1 {
  max-width: 18ch;
  font-size: clamp(28px, 4.9vmin, 52px);
}

.result_copy strong {
  color: var(--yellow-soft);
  font-size: clamp(16px, 2.45vmin, 30px);
  line-height: 1.18;
}

.result_copy .primary_button {
  width: min(100%, 320px);
  min-height: clamp(50px, 6.4dvh, 78px);
}

.result_preview_shell {
  justify-self: center;
  width: min(44vw, 29dvh, 350px);
  aspect-ratio: 2 / 3;
  padding: clamp(4px, 1vmin, 10px);
  background: #ffffff;
  box-shadow: var(--shadow);
}

.result_preview_column {
  justify-self: center;
  display: grid;
  justify-items: center;
  gap: clamp(10px, 1.7vmin, 18px);
}

.result_preview_shell img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #ffffff;
}

.result_download_button {
  min-height: clamp(44px, 5.6dvh, 70px);
  width: min(100%, 360px);
  padding-inline: clamp(28px, 5vw, 54px);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 2px solid rgba(255, 255, 255, 0.82);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  text-decoration: none;
  font-weight: 900;
}

.result_download_button.hidden {
  display: none;
}

.error_panel {
  max-width: 760px;
  max-height: calc(100dvh - (var(--pad-y) * 2));
  overflow: auto;
  padding: clamp(20px, 4vmin, 48px) clamp(22px, 5vmin, 58px);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  text-align: center;
  box-shadow: var(--shadow);
}

.error_panel .eyebrow {
  color: var(--green-700);
}

.error_panel h1 {
  max-width: none;
  color: var(--green-800);
  font-size: clamp(30px, 5.6vmin, 62px);
}

.error_panel p:not(.eyebrow) {
  margin: clamp(18px, 3vmin, 30px) 0 clamp(24px, 4vmin, 46px);
  color: rgba(16, 32, 23, 0.70);
  font-size: clamp(16px, 2.6vmin, 30px);
  line-height: 1.25;
  font-weight: 700;
}

.error_details {
  width: 100%;
  display: grid;
  gap: 10px;
  margin: 0 0 clamp(18px, 3vmin, 28px);
  text-align: left;
}

.variation_status {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 8px;
  background: #f2f6f1;
  color: var(--ink);
}

.variation_status strong {
  min-width: 0;
  color: var(--green-800);
  font-size: clamp(14px, 2vmin, 18px);
  line-height: 1.18;
}

.variation_status span {
  color: rgba(16, 32, 23, 0.68);
  font-size: clamp(12px, 1.8vmin, 15px);
  line-height: 1.25;
  font-weight: 700;
}

.variation_badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 78px;
  min-height: 30px;
  border-radius: 999px;
  padding: 0 10px;
  background: #d9ead8;
  color: var(--green-800);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.variation_status.error .variation_badge {
  background: #ffe2df;
  color: #9f1d16;
}

.variation_status.processing .variation_badge,
.variation_status.pending .variation_badge {
  background: #fff0bd;
  color: #6a4700;
}

.retry_options {
  width: 100%;
  display: grid;
  gap: 10px;
  margin-bottom: clamp(12px, 2vmin, 18px);
}

.retry_options .primary_button,
.retry_options .ghost_button,
.error_actions .ghost_button {
  width: 100%;
  min-height: clamp(44px, 5.8dvh, 64px);
  font-size: clamp(15px, 2.5vmin, 24px);
}

.retry_options .ghost_button,
.error_actions .ghost_button {
  background: #eef5ec;
  color: var(--green-800);
  border-color: #d8e4d5;
  box-shadow: none;
}

.error_actions {
  width: 100%;
  display: grid;
  gap: 10px;
}

.hidden {
  display: none !important;
}

.connection_badge {
  position: fixed;
  z-index: 20;
  right: max(16px, env(safe-area-inset-right));
  top: max(16px, env(safe-area-inset-top));
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--yellow);
  color: #3f2b08;
  font: 700 14px Arial, sans-serif;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: none;
}

.connection_badge.visible {
  opacity: 1;
  transform: translateY(0);
}

.settings_modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding:
    max(env(safe-area-inset-top), 18px)
    max(env(safe-area-inset-right), 18px)
    max(env(safe-area-inset-bottom), 18px)
    max(env(safe-area-inset-left), 18px);
  background: rgba(2, 19, 13, 0.62);
}

.settings_modal.hidden {
  display: none !important;
}

.settings_panel {
  width: min(100%, 520px);
  display: grid;
  gap: 22px;
  padding: clamp(22px, 4vmin, 36px);
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  box-shadow: var(--shadow);
}

.settings_header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
}

.settings_header .eyebrow {
  color: var(--green-700);
  margin-bottom: 8px;
}

.settings_header h2 {
  margin: 0;
  color: var(--green-800);
  font-size: clamp(30px, 5vmin, 46px);
  line-height: 1;
  font-weight: 800;
}

.settings_close {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 999px;
  background: #eef5ec;
  color: var(--green-800);
  font-size: 18px;
  font-weight: 800;
}

.settings_toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px;
  border-radius: 8px;
  background: #f4f7f2;
}

.settings_toggle span,
.settings_download span {
  display: grid;
  gap: 4px;
}

.settings_toggle strong,
.settings_download strong {
  color: var(--green-800);
  font-size: 20px;
  line-height: 1.1;
}

.settings_toggle small,
.settings_download small {
  color: rgba(16, 32, 23, 0.68);
  font-size: 14px;
  line-height: 1.3;
  font-weight: 700;
}

.settings_toggle input {
  appearance: none;
  width: 74px;
  height: 40px;
  flex: 0 0 auto;
  border-radius: 999px;
  background: #cfd8cc;
  position: relative;
  outline: none;
}

.settings_toggle input::before {
  content: "";
  position: absolute;
  left: 5px;
  top: 5px;
  width: 30px;
  height: 30px;
  border-radius: 999px;
  background: #ffffff;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.22);
  transition: transform 180ms ease;
}

.settings_toggle input:checked {
  background: var(--yellow);
}

.settings_toggle input:checked::before {
  transform: translateX(34px);
}

.settings_download {
  display: grid;
  gap: 14px;
  padding: 18px;
  border-radius: 8px;
  background: #f4f7f2;
}

.settings_download_button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  min-width: 190px;
  padding: 14px 34px;
  border-radius: 999px;
  background: var(--yellow);
  color: #3f2b08;
  text-decoration: none;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
}

.settings_download_button:hover,
.settings_download_button:focus-visible {
  outline: none;
  filter: brightness(1.04);
}

@keyframes loaderfill {
  0% {
    background-position: 0 0, 0 0;
  }
  100% {
    background-position: 96px 0, -220% 0;
  }
}

@keyframes loadertrack {
  0% {
    background-position-x: 0;
  }
  100% {
    background-position-x: 86px;
  }
}

@keyframes loaderpulse {
  0%,
  100% {
    opacity: 0.76;
  }
  50% {
    opacity: 1;
  }
}

@keyframes loadershine {
  0% {
    left: -35%;
  }
  100% {
    left: 110%;
  }
}

@keyframes countdownpop {
  0% {
    opacity: 0;
    transform: scale(0.72);
  }
  16% {
    opacity: 1;
    transform: scale(1.04);
  }
  78% {
    opacity: 1;
    transform: scale(1);
  }
  100% {
    opacity: 0.16;
    transform: scale(0.9);
  }
}

@media (orientation: portrait) {
  .screen_idle {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(220px, 35.5dvh) auto minmax(0, 1fr);
    justify-items: center;
    text-align: center;
  }

  .idle_content {
    width: min(100%, 940px);
    justify-items: center;
    align-self: start;
  }

  .brand_row {
    width: min(100%, 720px);
  }

  .name_panel {
    max-width: 760px;
    text-align: center;
  }

  .name_panel h1 {
    justify-self: center;
  }

  .virtual_keyboard {
    max-width: 760px;
    justify-self: center;
  }

  .camera_panel {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "copy"
      "view"
      "actions"
      "file";
    gap: clamp(10px, 2.2vmin, 24px);
    justify-items: center;
    align-content: center;
  }

  .camera_head {
    max-width: 720px;
    text-align: center;
    justify-items: center;
  }

  .camera_view {
    width: min(58vw, 35dvh, 450px);
  }

  .confirm_panel {
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "copy"
      "preview"
      "actions";
    justify-items: center;
    text-align: center;
  }

  .confirm_copy {
    max-width: 720px;
    text-align: center;
    justify-items: center;
  }

  .captured_preview {
    width: min(58vw, 34dvh, 430px);
  }

  .result_layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
    gap: clamp(12px, 2.4vmin, 28px);
    justify-items: center;
    text-align: center;
  }

  .result_copy {
    justify-items: center;
  }

  .result_copy h1 {
    max-width: 18ch;
  }

  .result_preview_shell {
    width: min(54vw, 29dvh, 350px);
  }
}

@media (orientation: landscape) {
  :root {
    --pad-y: clamp(12px, 2.8dvh, 34px);
    --stadium-height: clamp(190px, 34vw, 460px);
    --stadium-safe-bottom: clamp(92px, calc(var(--stadium-height) * 0.34), 170px);
  }

  .brand_row {
    width: min(100%, 640px);
  }

  .brand_logo {
    width: clamp(132px, 18vmin, 230px);
  }

  .brand_trophy {
    width: clamp(86px, 12vmin, 150px);
  }

  .screen_idle {
    grid-template-rows: minmax(118px, 31dvh) auto minmax(0, 1fr);
    row-gap: clamp(4px, 1dvh, 14px);
  }

  .idle_mark {
    width: min(48vw, 430px);
    margin-bottom: 0;
  }

  .idle_trophy {
    width: min(40vw, 360px);
  }

  .idle_content {
    width: min(74vw, 780px);
  }

  .idle_choice_button {
    min-height: clamp(92px, 19dvh, 150px);
    padding: clamp(14px, 3dvh, 26px) clamp(34px, 6vw, 72px);
    font-size: clamp(24px, 5.5vmin, 48px);
    line-height: 1.16;
  }

  .idle_player_silhouette {
    width: min(27vw, 330px);
    max-height: 40dvh;
    bottom: clamp(12px, 2dvh, 26px);
  }

  .screen[data-screen="name"] .name_panel {
    gap: clamp(8px, 1.3dvh, 14px);
  }

  .screen[data-screen="name"] .name_panel h1 {
    font-size: clamp(34px, 5.7vmin, 58px);
  }

  .screen[data-screen="name"] .name_panel input {
    min-height: clamp(52px, 6dvh, 70px);
  }

  .screen[data-screen="name"] .keyboard_key {
    min-height: clamp(40px, 5.5dvh, 68px);
  }

  .camera_view,
  .captured_preview {
    width: min(32vw, 36dvh, 360px);
  }

  .result_preview_shell {
    width: min(28vw, 36dvh, 340px);
  }

  .screen[data-screen="result"] .result_layout {
    width: min(100%, 980px);
    grid-template-columns: minmax(0, 0.92fr) minmax(240px, 0.58fr);
    gap: clamp(18px, 4vw, 52px);
    align-self: start;
    margin-top: clamp(8px, 2dvh, 22px);
  }

  .screen[data-screen="result"] .result_copy h1 {
    max-width: 13ch;
    font-size: clamp(30px, 5.2vmin, 58px);
  }

  .screen[data-screen="result"] .result_preview_shell {
    width: min(25vw, 48dvh, 320px);
  }
}

@media (orientation: landscape) and (max-height: 620px) {
  :root {
    --pad-y: clamp(12px, 3dvh, 28px);
    --stadium-height: clamp(150px, 30vw, 320px);
    --stadium-safe-bottom: clamp(82px, calc(var(--stadium-height) * 0.36), 130px);
  }

  .brand_row {
    width: min(100%, 560px);
  }

  .brand_logo {
    width: clamp(118px, 22vmin, 176px);
  }

  .brand_trophy {
    width: clamp(78px, 15vmin, 124px);
  }

  .screen_idle {
    grid-template-rows: minmax(92px, 27dvh) auto minmax(0, 1fr);
  }

  .idle_trophy {
    width: min(36vw, 270px);
  }

  .idle_choice_button {
    min-height: clamp(78px, 18dvh, 118px);
    font-size: clamp(20px, 5vmin, 36px);
  }

  .idle_player_silhouette {
    width: min(22vw, 240px);
  }

  h1 {
    font-size: clamp(28px, 6vmin, 58px);
  }

  .camera_view {
    width: min(28vw, 44dvh, 360px);
  }

  .captured_preview {
    width: min(28vw, 44dvh, 340px);
  }

  .result_preview_shell {
    width: min(30vw, 52dvh, 380px);
  }
}

@media (max-height: 620px) {
  .screen[data-screen="name"] {
    row-gap: 6px;
  }

  .screen[data-screen="name"] .name_panel {
    gap: 8px;
  }

  .screen[data-screen="name"] .name_panel label {
    margin-top: 2px;
  }

  .screen[data-screen="name"] .name_panel input {
    min-height: 52px;
  }

  .screen[data-screen="name"] .virtual_keyboard {
    gap: 5px;
    padding: 6px;
  }

  .screen[data-screen="name"] .keyboard_row {
    gap: 4px;
  }

  .screen[data-screen="name"] .keyboard_key {
    min-height: 46px;
    font-size: 15px;
  }

  .screen[data-screen="name"] .keyboard_key.action {
    font-size: 12px;
  }
}

@media (max-width: 360px) {
  .screen[data-screen="name"] {
    padding-top: max(env(safe-area-inset-top), 8px);
    padding-bottom: max(env(safe-area-inset-bottom), 8px);
  }

  .brand_row {
    gap: 16px;
  }

  .brand_logo {
    width: 120px;
  }

  .brand_trophy {
    width: 78px;
  }

  .screen[data-screen="name"] .name_panel {
    gap: 6px;
  }

  .screen[data-screen="name"] .name_panel h1 {
    font-size: 32px;
  }

  .screen[data-screen="name"] .name_panel input {
    min-height: 48px;
  }

  .screen[data-screen="name"] .virtual_keyboard {
    gap: 4px;
    padding: 5px;
  }

  .screen[data-screen="name"] .keyboard_row {
    gap: 3px;
  }

  .screen[data-screen="name"] .keyboard_key {
    min-height: 43px;
    font-size: 14px;
  }

  .screen[data-screen="name"] .keyboard_key.action {
    font-size: 11px;
  }
}

@media (min-width: 720px) {
  .retry_options {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .retry_options .primary_button {
    grid-column: 1 / -1;
  }
}

@media (max-width: 520px), (max-height: 520px) {
  .primary_button,
  .ghost_button {
    min-height: 50px;
    padding-inline: 18px;
    font-size: clamp(15px, 4vmin, 20px);
  }

  .camera_actions,
  .confirm_actions {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .screen,
  .connection_badge,
  .settings_button,
  .settings_toggle input::before {
    transition: none;
    animation: none;
  }
}
