#play-container {
  width: 100vw;
  width: 100dvw;
  height: 100vh;
  height: 100dvh;
  height: -webkit-fill-available;
  position: relative;
  overflow: hidden;
  touch-action: none;
  background-color: var(--bg-primary);
  user-select: none;
  -webkit-user-select: none;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

/* Mobile HUD */
.mobile-hud {
  position: absolute;
  top: max(8px, env(safe-area-inset-top));
  left: max(8px, env(safe-area-inset-left));
  right: max(8px, env(safe-area-inset-right));
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  z-index: 25;
}

.hud-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
}

.btn-hud-action {
  cursor: pointer;
  border: 1px solid var(--border-subtle);
  transition: all 0.15s ease;
  user-select: none;
  -webkit-user-select: none;
  color: var(--text-secondary);
}

.btn-hud-action:active {
  transform: scale(0.94);
  background: #e2e8f0;
}

.fs-icon {
  font-size: 0.85rem;
  line-height: 1;
}

.hud-pill {
  padding: 6px 10px;
  border-radius: 16px;
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 5px;
  pointer-events: auto;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
  white-space: nowrap;
}

.status-tether {
  position: absolute;
  top: calc(max(8px, env(safe-area-inset-top)) + 42px);
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 12px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.95);
  border: 1.5px solid var(--accent-blue);
  color: var(--accent-blue);
  font-size: 0.72rem;
  font-weight: 700;
  text-align: center;
  max-width: min(92vw, 360px);
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.15);
  z-index: 15;
  pointer-events: none;
  line-height: 1.3;
}

/* Compass arrow (Hidden to restrict player info so they must look at TV) */
#compass {
  display: none !important;
}

#compass-arrow {
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 16px solid var(--accent-gold);
  transform-origin: center 8px;
}

/* Touch Controls */
.touch-controls {
  position: absolute;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: max(16px, env(safe-area-inset-left));
  right: max(16px, env(safe-area-inset-right));
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  pointer-events: none;
  z-index: 10;
}

/* Virtual Joystick */
#joystick-zone {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.85);
  border: 2px dashed rgba(2, 132, 199, 0.4);
  box-shadow: 0 6px 18px rgba(15, 23, 42, 0.1);
  position: relative;
  pointer-events: auto;
  touch-action: none;
}

#joystick-knob {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: radial-gradient(circle, #0284c7 0%, #0369a1 100%);
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.4);
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
  transition: transform 0.05s ease-out;
}

/* Action Button */
#action-btn {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  border: 3px solid #ffffff;
  color: #ffffff;
  font-family: var(--font-main);
  font-weight: 900;
  font-size: 0.95rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-shadow: 0 6px 20px rgba(217, 119, 6, 0.4);
  pointer-events: auto;
  touch-action: none;
  cursor: pointer;
  transition: transform 0.1s, filter 0.1s;
}

#action-btn:active {
  transform: scale(0.92);
  filter: brightness(0.9);
}

#action-btn span {
  font-size: 0.7rem;
  font-weight: 700;
  opacity: 0.9;
}

/* Name Modal */
#join-modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}

.modal-box {
  width: 100%;
  max-width: 380px;
  padding: 32px 24px;
  text-align: center;
  background: #ffffff;
}

.modal-box h2 {
  font-size: 1.5rem;
  margin-bottom: 6px;
  color: #0f172a;
}

.modal-box p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 22px;
}

.input-field {
  width: 100%;
  padding: 14px 16px;
  border-radius: 10px;
  border: 2px solid var(--border-subtle);
  background: #f8fafc;
  color: #0f172a;
  font-family: var(--font-main);
  font-size: 1.1rem;
  font-weight: 600;
  text-align: center;
  outline: none;
  margin-bottom: 20px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-field:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

/* iOS Tips Toast */
.ios-toast {
  position: fixed;
  top: max(68px, calc(env(safe-area-inset-top) + 56px));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 28px);
  max-width: 420px;
  background: #0f172a;
  color: #f8fafc;
  padding: 12px 16px;
  border-radius: 14px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.3);
  z-index: 1000;
  display: none;
  border: 1px solid rgba(255, 255, 255, 0.15);
  animation: slideToast 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.ios-toast.show {
  display: block !important;
}

.toast-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.82rem;
  line-height: 1.4;
}

.toast-content b {
  color: #38bdf8;
}

#btn-close-toast {
  background: rgba(255, 255, 255, 0.12);
  border: none;
  color: #ffffff;
  font-size: 0.9rem;
  font-weight: bold;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#btn-close-toast:active {
  background: rgba(255, 255, 255, 0.25);
}

@keyframes slideToast {
  from {
    opacity: 0;
    transform: translate(-50%, -15px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* Small mobile portrait (<= 420px width) */
@media (max-width: 420px) {
  .hud-pill {
    padding: 5px 8px;
    font-size: 0.70rem;
    gap: 3px;
  }
  #action-btn {
    width: 90px;
    height: 90px;
    font-size: 0.82rem;
  }
  #joystick-zone {
    width: 116px;
    height: 116px;
  }
  #joystick-knob {
    width: 46px;
    height: 46px;
  }
  .touch-controls {
    bottom: max(14px, env(safe-area-inset-bottom));
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
  }
}

/* Compact layout for landscape phones (height <= 520px) */
@media (max-height: 520px) {
  .status-tether {
    top: calc(max(4px, env(safe-area-inset-top)) + 36px);
    font-size: 0.68rem;
    padding: 2px 10px;
    max-width: 320px;
  }
  #joystick-zone {
    width: 96px;
    height: 96px;
  }
  #joystick-knob {
    width: 38px;
    height: 38px;
  }
  #action-btn {
    width: 76px;
    height: 76px;
    font-size: 0.72rem;
  }
  .touch-controls {
    bottom: max(8px, env(safe-area-inset-bottom));
    left: max(10px, env(safe-area-inset-left));
    right: max(10px, env(safe-area-inset-right));
  }
}

