/* Palette taken from the Godot prototype (game/scripts/maze_view.gd on main).
   The grey background and button greys are Godot 4's default clear colour and
   default button theme, which is what the prototype shipped with. */
:root {
  --bg: #4d4d4d;
  --page: #262626;
  --text: #e0e0e0;
  --btn: #2e2e2e;
  --btn-hover: #414141;
  --btn-down: #1f1f1f;
  --floor: #1b2230;
  --wall: #4de1c1;
  --goal: #f6c453;
  --player: #ff7a6b;
  --pad-btn: clamp(52px, 9vh, 76px);
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--page);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  height: 100dvh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  outline: none;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

/* HUD: one line top-left, as in the prototype. */
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(14px, env(safe-area-inset-top)) 16px 10px;
}

.hud-line {
  margin: 0;
  display: flex;
  gap: 14px;
  font-size: 16px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.tag {
  flex: none;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 3px 9px;
  border: 1px solid rgba(224, 224, 224, 0.35);
  border-radius: 999px;
  color: rgba(224, 224, 224, 0.75);
}

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
}

.stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.hint {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 3px;
  margin: 0;
  text-align: center;
  font-size: 12px;
  color: rgba(224, 224, 224, 0.55);
  pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
  .hint { display: block; }
}

/* Celebration card over the solved maze. */
.toast {
  position: absolute;
  left: 50%;
  top: 50%;
  min-width: 190px;
  padding: 14px 22px 16px;
  text-align: center;
  background: rgba(27, 34, 48, 0.94);
  border: 2px solid var(--goal);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.85);
  transition: opacity 180ms ease-out, transform 260ms cubic-bezier(0.2, 1.4, 0.4, 1);
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.toast strong {
  display: block;
  color: var(--goal);
  font-size: 24px;
  line-height: 1.2;
}

.toast span {
  display: block;
  margin-top: 4px;
  font-size: 14px;
}

/* D-pad: up on top, left/down/right below, anchored bottom-centre. */
.pad {
  display: grid;
  grid-template-columns: repeat(3, var(--pad-btn));
  grid-template-rows: repeat(2, var(--pad-btn));
  gap: 8px;
  justify-content: center;
  padding: 18px 0 max(20px, env(safe-area-inset-bottom));
}

.pad button {
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 4px;
  background: var(--btn);
  color: var(--text);
  font: inherit;
  font-size: calc(var(--pad-btn) * 0.34);
  line-height: 1;
  cursor: pointer;
  touch-action: none;
  transition: background-color 80ms;
}

.pad .up { grid-column: 2; grid-row: 1; }
.pad .left { grid-column: 1; grid-row: 2; }
.pad .down { grid-column: 2; grid-row: 2; }
.pad .right { grid-column: 3; grid-row: 2; }

@media (hover: hover) {
  .pad button:hover { background: var(--btn-hover); }
}

.pad button.is-down,
.pad button:active { background: var(--btn-down); }

.pad button:focus-visible {
  outline: 2px solid var(--wall);
  outline-offset: 2px;
}

#app.is-solved .pad button { opacity: 0.5; }

/* Desktop with room to spare: a phone-shaped frame. */
@media (min-width: 560px) and (min-height: 760px) {
  #app {
    width: min(430px, calc((100dvh - 64px) * 0.5));
    height: min(880px, calc(100dvh - 64px));
    border-radius: 28px;
    box-shadow: 0 0 0 10px #161616, 0 24px 60px rgba(0, 0, 0, 0.5);
  }
}

/* Wide but short, e.g. the homepage iframe: a centred full-height column. */
@media (min-width: 560px) and (max-height: 759px) {
  #app { width: min(460px, 100%); }
}

@media (prefers-reduced-motion: reduce) {
  .toast { transition: none; }
}
