:root { color-scheme: dark; font-family: system-ui, sans-serif; color: #fff3d6; background: #123e3c; }
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; }
button { font: inherit; cursor: pointer; }

#game-shell {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
  background: #123e3c;
}

.player-bar {
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 0 0 60px;
  min-height: 0;
  gap: 12px;
  padding: 5px max(14px, env(safe-area-inset-right)) 5px max(14px, env(safe-area-inset-left));
  background: linear-gradient(90deg, #103d39 0%, #164d47 52%, #103d39 100%);
  border-bottom: 1px solid #bd9a58;
  box-shadow: 0 3px 18px #071c1b88;
}

.brand { display: flex; align-items: center; }
.brand img { display: block; width: auto; height: 50px; }
#fullscreen, #retry, #dismiss-note {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 40px;
  padding: 8px 15px;
  border: 1px solid #fbe3a2;
  border-radius: 10px;
  background: linear-gradient(#ffe398, #e7b94f);
  box-shadow: inset 0 1px #fff3c5, 0 3px 0 #8d5e28;
  color: #244033;
  font-size: 14px;
  font-weight: 800;
}
#fullscreen:hover, #retry:hover, #dismiss-note:hover { filter: brightness(1.08); }
#fullscreen:focus-visible, #retry:focus-visible, #dismiss-note:focus-visible, .brand:focus-visible {
  outline: 3px solid #87f8e9;
  outline-offset: 3px;
}
#fullscreen svg { width: 18px; height: 18px; flex: none; }

.game-viewport {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background: #123e3c url('feature-background.webp') center / cover no-repeat;
}
#game { display: block; width: 100%; height: 100%; outline: none; }
/* The game owns every touch: no double-tap zoom, pinch, text selection, magnifier or callout. */
#game {
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}
html, body { overscroll-behavior: none; }

#loading {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: linear-gradient(90deg, #072e2dc9 0%, #0b38396e 60%, #12403835 100%),
    url('feature-background.webp') center / cover no-repeat;
}
.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: min(100%, 430px);
  padding: 22px 24px 26px;
  border: 1px solid #e4c47880;
  border-radius: 20px;
  background: #103e3cdd;
  box-shadow: 0 20px 80px #001b23a6, inset 0 1px #fff3c547;
  text-align: center;
  backdrop-filter: blur(9px);
}
.loading-content img { width: min(80%, 300px); height: auto; margin-bottom: 6px; }
.loading-content strong { font-size: clamp(16px, 2vw, 21px); }
#progress { width: 100%; height: 14px; margin: 18px 0 6px; accent-color: #f2c65d; }
#progress-text { color: #d9f9ef; font-variant-numeric: tabular-nums; font-weight: 800; }

#controls-choice {
  width: 100%;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid #e4c47859;
}
#controls-title { margin: 0 0 4px; font-size: 18px; font-weight: 800; }
#controls-text { margin: 0 0 14px; color: #d9f9ef; font-size: 13px; line-height: 1.4; }
.controls-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.controls-options button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 86px;
  padding: 10px 8px;
  border: 1px solid #fbe3a2;
  border-radius: 12px;
  background: linear-gradient(#ffe398, #e7b94f);
  box-shadow: inset 0 1px #fff3c5, 0 3px 0 #8d5e28;
  color: #244033;
  font-size: 14px;
  font-weight: 800;
  touch-action: manipulation;
}
.controls-options svg { width: 34px; height: 34px; flex: none; }
.controls-options button:hover { filter: brightness(1.08); }
.controls-options button:focus-visible { outline: 3px solid #87f8e9; outline-offset: 3px; }

/* The game is laid out for landscape, like the phone apps. */
#rotate {
  position: absolute;
  z-index: 6;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  background: #0b3433f2;
  font-size: 18px;
  font-weight: 800;
  text-align: center;
}
#rotate svg { width: 64px; height: 64px; color: #f2c65d; }
#rotate p { margin: 0; }
@media (orientation: portrait) and (pointer: coarse) {
  #rotate { display: flex; }
}

#error {
  position: absolute;
  z-index: 5;
  top: 18px;
  left: 50%;
  width: min(90%, 520px);
  padding: 14px 18px;
  transform: translateX(-50%);
  border: 1px solid #ffbd9d;
  border-radius: 12px;
  background: #592c2ae8;
  box-shadow: 0 12px 38px #001b23a6;
  text-align: center;
}
#error p { margin: 0 0 10px; line-height: 1.4; }

#guest-note {
  position: absolute;
  z-index: 4;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  display: flex;
  align-items: center;
  gap: 14px;
  width: min(660px, calc(100% - 28px));
  padding: 10px 12px 10px 16px;
  border: 1px solid #e4c4788c;
  border-radius: 12px;
  background: #0e393acb;
  box-shadow: 0 8px 28px #001b23a0;
  backdrop-filter: blur(7px);
}
#guest-note p { margin: 0; color: #f4f1df; font-size: 13px; line-height: 1.4; }
#dismiss-note { flex: none; min-height: 34px; padding: 6px 10px; font-size: 12px; }
#loading[hidden], #error[hidden], #guest-note[hidden], #retry[hidden], #fullscreen[hidden], #controls-choice[hidden] { display: none; }

#game-shell:fullscreen, #game-shell:-webkit-full-screen { width: 100vw; height: 100vh; }
#game-shell:fullscreen .player-bar { flex-basis: 48px; }
#game-shell:fullscreen .brand img { height: 40px; }

@media (max-width: 700px) {
  .player-bar { flex-basis: 50px; }
  .brand img { height: 42px; }
  #fullscreen { min-height: 36px; padding: 6px 9px; font-size: 12px; }
  #fullscreen svg { width: 16px; height: 16px; }
  #guest-note { align-items: flex-start; flex-direction: column; gap: 8px; width: min(420px, calc(100% - 28px)); }
  .loading-content { padding: 16px 18px 20px; }
}
@media (max-height: 500px) {
  .player-bar { flex-basis: 42px; }
  .brand img { height: 36px; }
  #guest-note { max-width: 420px; }
  #guest-note p { font-size: 11px; }
}
