/* Shellout page shell. The game itself is drawn on a canvas inside #game-container. */
:root {
  --wood-dark: #3b2414;
  --wood: #8b5a2b;
  --sand: #f5e6c4;
  --sea: #0e7490;
  --ink: #1f2933;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: var(--wood-dark);
  font-family: "Fredoka", "Trebuchet MS", Arial, sans-serif;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

.stage {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  /* The wood texture carries the SEATRU and TechTurtle logos (SRS SF-09) */
  background: var(--wood-dark) url("../assets/ui/wood-texture.jpg") center / cover no-repeat;
  padding: 16px;
}

/* Keep a 16:9 frame that fits any screen */
.frame {
  width: min(100%, calc((100dvh - 32px) * 16 / 9));
  aspect-ratio: 16 / 9;
  border: 6px solid var(--wood);
  border-radius: 10px;
  box-shadow: 0 0 30px rgba(0, 0, 0, 0.5);
  background: #000;
  overflow: hidden;
  position: relative;
}

/* In full screen, the frame fills the whole screen */
.frame:fullscreen { width: 100%; height: 100%; border: 0; border-radius: 0; box-shadow: none; }
.frame:-webkit-full-screen { width: 100%; height: 100%; border: 0; border-radius: 0; box-shadow: none; }

#game-container {
  width: 100%;
  height: 100%;
  position: relative;
}

#game-container canvas {
  display: block;
}

.rotate-hint {
  display: none;
  color: var(--sand);
  margin: 12px 0 0;
  font-size: 15px;
  text-align: center;
}

/* Phones: drop the decorative frame and use the whole screen */
@media (max-width: 900px), (max-height: 500px) {
  .stage { padding: 0; background: #000; }
  .frame {
    width: min(100vw, calc(100dvh * 16 / 9));
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
}

@media (orientation: portrait) and (max-width: 900px) {
  .rotate-hint { display: block; }
}

/* ---------- "Play full screen" guide for phones and tablets ---------- */
.install[hidden] { display: none; }
.install {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  background: rgba(8, 22, 30, 0.78);
}
.install-card {
  width: min(640px, 100%);
  max-height: 100%;
  overflow: auto;
  background: var(--sand);
  color: var(--ink);
  border: 5px solid var(--wood);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  padding: 14px 18px 16px;
  text-align: left;
  -webkit-user-select: text;
  user-select: text;
  touch-action: auto;
}
.install-head { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.install-head img { width: 46px; height: 46px; border-radius: 10px; image-rendering: pixelated; flex: none; }
.install-head h2 { margin: 0; font-size: 21px; color: var(--wood-dark); line-height: 1.15; }
.install-head p { margin: 2px 0 0; font-size: 14px; color: #5b6770; }
.install-steps { margin: 6px 0 12px; padding: 0; list-style: none; counter-reset: s; }
.install-steps li {
  counter-increment: s;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 0;
  font-size: 16px;
  line-height: 1.3;
  border-top: 1px dashed rgba(139, 90, 43, 0.35);
}
.install-steps li:first-child { border-top: 0; }
.install-steps li::before {
  content: counter(s);
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--sea);
  color: #fff;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}
.install-steps b { color: var(--wood-dark); }
.install-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  width: 26px;
  height: 26px;
  margin: 0 2px;
  border-radius: 6px;
  background: #fff;
  border: 1px solid #c9b48a;
  color: #0a84ff;
  font-weight: 700;
}
.install-icon svg { width: 17px; height: 17px; }
.install-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.install-actions button {
  font: inherit;
  font-weight: 600;
  font-size: 16px;
  padding: 10px 16px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  touch-action: manipulation;
  color: #fff;
  background: #6b7280;
}
.install-actions .primary { background: #2f9e44; flex: 1 1 auto; }
.install-actions .sea { background: var(--sea); }
.install-never {
  display: block;
  margin: 10px auto 0;
  background: none;
  border: 0;
  color: #5b6770;
  font: inherit;
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
}

/* Phones held sideways are short: make the guide more compact */
@media (max-height: 460px) {
  .install-card { padding: 10px 14px 10px; border-width: 4px; }
  .install-head { margin-bottom: 4px; }
  .install-head img { width: 36px; height: 36px; }
  .install-head h2 { font-size: 18px; }
  .install-head p { font-size: 12.5px; }
  .install-steps { margin: 2px 0 8px; }
  .install-steps li { font-size: 14px; padding: 4px 0; }
  .install-steps li::before { width: 24px; height: 24px; font-size: 13px; }
  .install-icon { width: 22px; height: 22px; }
  .install-icon svg { width: 15px; height: 15px; }
  .install-actions button { padding: 8px 14px; font-size: 15px; }
  .install-note { display: none; }
  .install-never { margin-top: 6px; }
}

/* ---------- DOM overlays (error screen, name entry) ---------- */
.so-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 20, 30, 0.82);
  padding: 16px;
}

.so-card {
  background: var(--sand);
  color: var(--ink);
  border: 4px solid var(--wood);
  border-radius: 14px;
  padding: 22px 24px;
  width: min(520px, 100%);
  max-height: 100%;
  overflow: auto;
  text-align: center;
  user-select: text;
  -webkit-user-select: text;
}

.so-card h2 { margin: 0 0 8px; color: var(--wood-dark); font-size: 24px; }
.so-card p { margin: 6px 0 14px; line-height: 1.4; }
.so-card pre {
  text-align: left;
  font-size: 12px;
  background: rgba(0, 0, 0, 0.08);
  padding: 8px;
  border-radius: 6px;
  white-space: pre-wrap;
  max-height: 120px;
  overflow: auto;
}

.so-card input {
  width: 100%;
  font: inherit;
  font-size: 20px;
  padding: 10px 12px;
  border: 2px solid var(--wood);
  border-radius: 8px;
  margin-bottom: 14px;
  user-select: text;
  -webkit-user-select: text;
  touch-action: auto;
}

.so-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

.so-btn {
  font: inherit;
  font-weight: 600;
  font-size: 18px;
  padding: 10px 20px;
  border-radius: 10px;
  border: 0;
  cursor: pointer;
  background: var(--sea);
  color: #fff;
  touch-action: manipulation;
}

.so-btn.secondary { background: #6b7280; }
.so-btn:hover { filter: brightness(1.1); }
