:root {
  color-scheme: dark;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background: #101a30;
  color: #f7f4e9;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(71, 133, 188, .22), transparent 56%),
    #101a30;
}

button, a { font: inherit; }
button { color: inherit; }

.game-shell {
  width: min(1120px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 28px 30px;
  display: flex;
  flex-direction: column;
}

.game-header {
  min-height: 48px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  color: #c9d5e6;
}

.back-link {
  width: fit-content;
  color: inherit;
  text-decoration: none;
  font-size: .9rem;
}

.back-link:hover { color: #fff1b8; }

.game-brand {
  display: flex;
  gap: 8px;
  align-items: center;
  color: #b7c5d8;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .16em;
}

.brand-mark { color: #ffd875; font-size: 1.2rem; }

.language-toggle {
  justify-self: end;
  border: 1px solid rgba(225, 233, 244, .26);
  border-radius: 999px;
  background: transparent;
  padding: 7px 12px;
  color: #f7f4e9;
  cursor: pointer;
  font-size: .76rem;
}

.language-toggle:hover { border-color: #ffd875; }

.game-content {
  width: min(960px, 100%);
  margin: 38px auto 0;
}

.title-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 8px;
  color: #f4cd75;
  font-size: .69rem;
  font-weight: 700;
  letter-spacing: .17em;
}

h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 5vw, 3.4rem);
  font-weight: 400;
  letter-spacing: -.035em;
}

.star-counter {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px 15px;
  border: 1px solid rgba(255, 226, 144, .34);
  border-radius: 14px;
  background: rgba(15, 25, 45, .68);
  color: #fff4cf;
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
}

.star-counter > span:first-child { color: #ffd45e; }
.star-divider { color: #8793a7; }

.game-frame {
  position: relative;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  min-height: 320px;
  border: 1px solid rgba(207, 220, 241, .24);
  border-radius: 24px;
  background: #8bc6dc;
  box-shadow: 0 28px 80px rgba(0, 0, 0, .3);
  isolation: isolate;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

.game-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(10, 20, 38, .2);
  backdrop-filter: blur(4px);
  transition: opacity .25s ease, visibility .25s ease;
}

.game-overlay.is-hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.overlay-card {
  width: min(420px, 100%);
  padding: 28px 30px 30px;
  border: 1px solid rgba(255, 255, 255, .24);
  border-radius: 22px;
  background: rgba(17, 29, 52, .9);
  text-align: center;
  box-shadow: 0 18px 55px rgba(0, 0, 0, .28);
}

.overlay-icon {
  margin-bottom: 6px;
  color: #ffd66c;
  font-size: 2rem;
  text-shadow: 0 0 28px rgba(255, 210, 91, .6);
}

.overlay-card .eyebrow { margin-bottom: 9px; }
.overlay-card h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.7rem, 5vw, 2.35rem);
  font-weight: 400;
}

.overlay-card > p:not(.eyebrow) {
  margin: 12px 0 22px;
  color: #d3deeb;
  line-height: 1.55;
}

.play-button {
  min-width: 138px;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, #ffe18d, #eab94e);
  padding: 12px 26px;
  color: #28314a;
  cursor: pointer;
  font-weight: 800;
  box-shadow: 0 6px 20px rgba(235, 187, 80, .25);
}

.play-button:hover { filter: brightness(1.08); transform: translateY(-1px); }
.play-button:focus-visible, .language-toggle:focus-visible, .touch-controls button:focus-visible {
  outline: 3px solid #fff3bb;
  outline-offset: 3px;
}

.toast {
  position: absolute;
  z-index: 2;
  top: 18px;
  left: 50%;
  opacity: 0;
  transform: translate(-50%, -8px);
  border: 1px solid rgba(255, 233, 166, .38);
  border-radius: 999px;
  background: rgba(19, 30, 50, .88);
  padding: 9px 16px;
  color: #fff1bb;
  font-size: .9rem;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}

.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

.touch-controls {
  position: absolute;
  z-index: 2;
  inset: auto 16px 16px;
  display: none;
  justify-content: space-between;
  align-items: end;
  pointer-events: none;
}

.touch-controls button {
  width: 46px;
  height: 46px;
  border: 1px solid rgba(255, 255, 255, .45);
  border-radius: 14px;
  background: rgba(14, 25, 44, .6);
  color: white;
  touch-action: none;
  user-select: none;
  pointer-events: auto;
}

.touch-pad { display: grid; gap: 5px; justify-items: center; }
.touch-pad > div { display: flex; gap: 5px; }
.touch-pad button { backdrop-filter: blur(5px); }
.jump-button {
  width: 74px !important;
  height: 74px !important;
  border-radius: 50% !important;
  background: rgba(200, 154, 57, .82) !important;
  font-size: .7rem;
  font-weight: 800;
  letter-spacing: .04em;
}
.touch-controls button:active { background: rgba(255, 220, 120, .82); color: #152038; }

.game-footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: #bcc9da;
  font-size: .84rem;
}

.game-footer p { margin: 17px 0 0; }
.game-footer span { margin: 0 7px; color: #f4cd75; }
.game-hint { color: #8fa0b6; text-align: right; }
.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;
}

@media (pointer: coarse), (max-width: 700px) {
  .touch-controls { display: flex; }
}

@media (max-width: 640px) {
  .game-shell { padding: 12px 14px 22px; }
  .game-content { margin-top: 30px; }
  .game-brand { font-size: .55rem; letter-spacing: .11em; }
  .title-row { align-items: center; }
  .star-counter { padding: 8px 11px; font-size: .95rem; }
  .game-frame { min-height: 420px; aspect-ratio: 4 / 5; border-radius: 18px; }
  .overlay-card { padding: 22px 18px 24px; }
  .game-footer { flex-direction: column; gap: 0; font-size: .76rem; }
  .game-footer p { margin-top: 13px; }
  .game-hint { text-align: left; }
}

@media (max-width: 420px) {
  .game-frame { min-height: 330px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
