:root {
  --bg: #1a2f1a;
  --trail: #2d4a2d;
  --grass: #243824;
  --ink: #f4f7ef;
  --muted: rgba(244, 247, 239, 0.72);
  --accent: #fbbf24;
  --shell: #fef3c7;
  --shell-dark: #e9d5a8;
  --frame: #0f1f0f;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  background: var(--frame);
  color: var(--ink);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
  user-select: none;
}

#app {
  max-width: 430px;
  margin: 0 auto;
  height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #0c180c 0%, var(--frame) 12%);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.bar {
  flex: 0 0 auto;
  padding: 10px 14px 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.bar h1 {
  margin: 0 0 4px;
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.hint {
  margin: 0 0 6px;
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.35;
}

.holding {
  margin: 0 0 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink);
}

.status {
  margin: 0;
  font-size: 0.8rem;
  color: var(--accent);
}

.bar-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  border-bottom: none;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.name-label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--muted);
  flex: 1 1 140px;
}

.name-label input {
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(0, 0, 0, 0.25);
  color: var(--ink);
  font-size: 0.95rem;
}

#reconnect {
  padding: 9px 14px;
  border-radius: 10px;
  border: 1px solid rgba(251, 191, 36, 0.35);
  background: rgba(251, 191, 36, 0.12);
  color: var(--accent);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
}

#reconnect:active {
  transform: scale(0.98);
}

.viewport {
  flex: 1 1 auto;
  position: relative;
  overflow: hidden;
  touch-action: none;
  background: radial-gradient(ellipse 120% 80% at 50% 0%, #2a4a2a 0%, var(--bg) 55%);
}

.world {
  position: absolute;
  top: 0;
  left: 0;
  will-change: transform;
}

.board {
  display: block;
  background-color: var(--grass);
  background-image: radial-gradient(circle at 20% 30%, rgba(80, 120, 80, 0.35) 0%, transparent 45%),
    radial-gradient(circle at 78% 62%, rgba(60, 100, 60, 0.28) 0%, transparent 40%),
    repeating-linear-gradient(
      90deg,
      transparent,
      transparent 43px,
      rgba(45, 74, 45, 0.35) 43px,
      rgba(45, 74, 45, 0.35) 44px
    ),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 43px,
      rgba(45, 74, 45, 0.25) 43px,
      rgba(45, 74, 45, 0.25) 44px
    );
}

.avatars {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.avatar {
  position: absolute;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.45);
  transform: translate(-50%, -50%);
  z-index: 3;
}

.avatar .tag {
  position: absolute;
  left: 50%;
  top: -18px;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  pointer-events: none;
}

.avatar.self {
  width: 16px;
  height: 16px;
  border-color: #fff;
  box-shadow: 0 0 0 2px rgba(251, 191, 36, 0.7), 0 2px 6px rgba(0, 0, 0, 0.5);
}

/* `display: flex` must not apply while [hidden] is set — it overrides the UA display:none for hidden. */
.win-overlay {
  position: absolute;
  inset: 0;
  z-index: 30;
  padding: 20px 16px;
  background: rgba(8, 18, 8, 0.88);
  backdrop-filter: blur(6px);
  pointer-events: auto;
}

.win-overlay:not([hidden]) {
  display: flex;
  align-items: center;
  justify-content: center;
}

.win-modal {
  text-align: center;
  max-width: 280px;
  padding: 22px 20px;
  border-radius: 18px;
  background: linear-gradient(165deg, rgba(55, 85, 55, 0.95) 0%, rgba(25, 45, 25, 0.98) 100%);
  border: 1px solid rgba(251, 191, 36, 0.35);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.win-kicker {
  margin: 0 0 8px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--accent);
}

.win-title {
  margin: 0 0 10px;
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.25;
  color: var(--ink);
}

.win-sub {
  margin: 0;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--muted);
}

.win-collect {
  margin: 14px 0 0;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--muted);
}
