:root {
  --bg-top: #F4F7FB;
  --bg-bottom: #E2E8F0;
  --ink-primary: #0F172A;
  --ink-secondary: #475569;
  --ink-muted: #94A3B8;
}

* {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(circle at 50% 18%, #F8FAFC 0%, var(--bg-top) 48%, var(--bg-bottom) 100%);
  color: var(--ink-primary);
  touch-action: manipulation;
}

.font-mono-num {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace;
  font-variant-numeric: tabular-nums;
}

/* Self-Contained Utility Classes (Zero External Network Requests) */
.relative { position: relative; }
.fixed { position: fixed; }
.absolute { position: absolute; }
.inset-0 { top: 0; right: 0; bottom: 0; left: 0; }
.top-0 { top: 0; }
.right-0 { right: 0; }
.bottom-0 { bottom: 0; }
.left-0 { left: 0; }
.-top-20 { top: -5rem; }
.-left-20 { left: -5rem; }
.-bottom-28 { bottom: -7rem; }
.-right-20 { right: -5rem; }
.top-1\/3 { top: 33.333333%; }
.left-1\/2 { left: 50%; }
.-translate-x-1\/2 { transform: translateX(-50%); }
.-translate-y-1\/2 { transform: translateY(-50%); }
.top-1\/3.left-1\/2.-translate-x-1\/2.-translate-y-1\/2 { transform: translate(-50%, -50%); }

.z-10 { z-index: 10; }
.z-20 { z-index: 20; }
.z-30 { z-index: 30; }
.z-40 { z-index: 40; }
.z-50 { z-index: 50; }

.flex { display: flex; }
.inline-flex { display: inline-flex; }
.inline-block { display: inline-block; }
.grid { display: grid; }
.hidden { display: none !important; }
.flex-col { flex-direction: column; }
.flex-1 { flex: 1 1 0%; }
.items-center { align-items: center; }
.items-baseline { align-items: baseline; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.gap-1\.5 { gap: 0.375rem; }
.gap-2 { gap: 0.5rem; }
.gap-2\.5 { gap: 0.625rem; }
.gap-3 { gap: 0.75rem; }

.w-full { width: 100%; }
.h-full { height: 100%; }
.w-1\.5 { width: 0.375rem; }
.h-1\.5 { height: 0.375rem; }
.w-2 { width: 0.5rem; }
.h-2 { height: 0.5rem; }
.w-2\.5 { width: 0.625rem; }
.h-2\.5 { height: 0.625rem; }
.w-3 { width: 0.75rem; }
.h-3 { height: 0.75rem; }
.w-4 { width: 1rem; }
.h-4 { height: 1rem; }
.w-5 { width: 1.25rem; }
.h-5 { height: 1.25rem; }
.w-6 { width: 1.5rem; }
.h-6 { height: 1.5rem; }
.w-7 { width: 1.75rem; }
.h-7 { height: 1.75rem; }
.w-9 { width: 2.25rem; }
.h-9 { height: 2.25rem; }
.w-10 { width: 2.5rem; }
.w-12 { width: 3rem; }
.h-12 { height: 3rem; }
.w-64 { width: 16rem; }
.h-64 { height: 16rem; }
.w-80 { width: 20rem; }
.h-80 { height: 20rem; }
.w-96 { width: 24rem; }
.h-96 { height: 24rem; }

.min-w-\[115px\] { min-width: 115px; }
.max-w-\[360px\] { max-width: 360px; }
.max-w-\[400px\] { max-width: 400px; }
.max-w-\[410px\] { max-width: 410px; }
.max-w-\[468px\] { max-width: 468px; }

.m-0 { margin: 0; }
.mx-auto { margin-left: auto; margin-right: auto; }
.my-1 { margin-top: 0.25rem; margin-bottom: 0.25rem; }
.mt-0\.5 { margin-top: 0.125rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-1\.5 { margin-top: 0.375rem; }
.mb-0\.5 { margin-bottom: 0.125rem; }
.mb-1 { margin-bottom: 0.25rem; }
.mb-1\.5 { margin-bottom: 0.375rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-5 { margin-bottom: 1.25rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mr-1 { margin-right: 0.25rem; }

.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-3\.5 { padding: 0.875rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.px-1\.5 { padding-left: 0.375rem; padding-right: 0.375rem; }
.px-2 { padding-left: 0.5rem; padding-right: 0.5rem; }
.px-2\.5 { padding-left: 0.625rem; padding-right: 0.625rem; }
.px-3 { padding-left: 0.75rem; padding-right: 0.75rem; }
.px-3\.5 { padding-left: 0.875rem; padding-right: 0.875rem; }
.px-4 { padding-left: 1rem; padding-right: 1rem; }
.py-0\.5 { padding-top: 0.125rem; padding-bottom: 0.125rem; }
.py-1 { padding-top: 0.25rem; padding-bottom: 0.25rem; }
.py-2\.5 { padding-top: 0.625rem; padding-bottom: 0.625rem; }
.py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
.py-3\.5 { padding-top: 0.875rem; padding-bottom: 0.875rem; }
.pr-2 { padding-right: 0.5rem; }

.rounded-md { border-radius: 0.375rem; }
.rounded-lg { border-radius: 0.5rem; }
.rounded-xl { border-radius: 0.75rem; }
.rounded-2xl { border-radius: 1rem; }
.rounded-3xl { border-radius: 1.5rem; }
.rounded-full { border-radius: 9999px; }
.rounded-tl-lg { border-top-left-radius: 0.5rem; }
.rounded-tr-lg { border-top-right-radius: 0.5rem; }
.rounded-bl-lg { border-bottom-left-radius: 0.5rem; }
.rounded-br-lg { border-bottom-right-radius: 0.5rem; }

.border { border-width: 1px; border-style: solid; }
.border-t-2 { border-top-width: 2px; border-top-style: solid; }
.border-b-2 { border-bottom-width: 2px; border-bottom-style: solid; }
.border-l-2 { border-left-width: 2px; border-left-style: solid; }
.border-r-2 { border-right-width: 2px; border-right-style: solid; }
.border-slate-200\/60 { border-color: rgba(226, 232, 240, 0.6); }
.border-slate-200\/70 { border-color: rgba(226, 232, 240, 0.7); }
.border-slate-200\/80 { border-color: rgba(226, 232, 240, 0.8); }
.border-slate-200\/90 { border-color: rgba(226, 232, 240, 0.9); }
.border-slate-300\/70 { border-color: rgba(203, 213, 225, 0.7); }
.border-sky-200 { border-color: #C2E3F5; }
.border-sky-200\/80 { border-color: rgba(194, 227, 245, 0.8); }
.border-rose-200 { border-color: #F8D3D8; }
.border-rose-200\/70 { border-color: rgba(248, 211, 216, 0.7); }
.border-rose-200\/90 { border-color: rgba(248, 211, 216, 0.9); }
.border-white\/90 { border-color: rgba(255, 255, 255, 0.9); }

.bg-white\/70 { background-color: rgba(255, 255, 255, 0.7); }
.bg-white\/80 { background-color: rgba(255, 255, 255, 0.8); }
.bg-white\/85 { background-color: rgba(255, 255, 255, 0.85); }
.bg-white\/90 { background-color: rgba(255, 255, 255, 0.9); }
.bg-slate-100 { background-color: #F1F5F9; }
.bg-slate-100\/80 { background-color: rgba(241, 245, 249, 0.8); }
.bg-slate-100\/85 { background-color: rgba(241, 245, 249, 0.85); }
.bg-slate-200\/75 { background-color: rgba(226, 232, 240, 0.75); }
.bg-slate-900\/25 { background-color: rgba(15, 23, 42, 0.25); }
.bg-sky-100 { background-color: #E4F1FA; }
.bg-sky-100\/90 { background-color: rgba(228, 241, 250, 0.9); }
.bg-sky-200 { background-color: #C2E3F5; }
.bg-sky-500 { background-color: #299BCE; }
.bg-cyan-500 { background-color: #20A4BA; }
.bg-teal-100 { background-color: #D2F5EE; }
.bg-emerald-500 { background-color: #25A47A; }
.bg-indigo-200 { background-color: #CED6F7; }
.bg-rose-50 { background-color: #FDF3F3; }
.bg-rose-50\/70 { background-color: rgba(253, 243, 243, 0.7); }
.bg-rose-100 { background-color: #FCE7E9; }
.bg-amber-100 { background-color: #F7EFCE; }

.text-white { color: #FFFFFF; }
.text-slate-300 { color: #CBD5E1; }
.text-slate-400 { color: #94A3B8; }
.text-slate-500 { color: #64748B; }
.text-slate-700 { color: #334155; }
.text-slate-800 { color: #1E293B; }
.text-slate-900 { color: #0F172A; }
.text-sky-600 { color: #1B7CAE; }
.text-sky-700 { color: #17638D; }
.text-teal-600 { color: #1E837A; }
.text-emerald-600 { color: #178462; }
.text-indigo-600 { color: #615AD1; }
.text-rose-500 { color: #DD566D; }
.text-rose-600\/85 { color: rgba(200, 54, 86, 0.85); }
.text-rose-700 { color: #A82847; }
.text-amber-800 { color: #82441F; }

.text-\[10px\] { font-size: 10px; }
.text-\[11px\] { font-size: 11px; }
.text-xs { font-size: 0.75rem; line-height: 1rem; }
.text-sm { font-size: 0.875rem; line-height: 1.25rem; }
.text-base { font-size: 1rem; line-height: 1.5rem; }
.text-lg { font-size: 1.125rem; line-height: 1.75rem; }
.text-2xl { font-size: 1.5rem; line-height: 2rem; }
.text-3xl { font-size: 1.875rem; line-height: 2.25rem; }
.text-4xl { font-size: 2.25rem; line-height: 2.5rem; }

.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.font-extrabold { font-weight: 800; }
.uppercase { text-transform: uppercase; }
.tracking-tight { letter-spacing: -0.025em; }
.tracking-wide { letter-spacing: 0.025em; }
.tracking-wider { letter-spacing: 0.05em; }
.leading-none { line-height: 1; }
.leading-snug { line-height: 1.375; }
.text-left { text-align: left; }
.text-center { text-align: center; }
.text-right { text-align: right; }

.shadow-sm { box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05); }
.shadow-2xl { box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.22); }
.shadow-inner { box-shadow: inset 0 2px 4px 0 rgba(15, 23, 42, 0.05); }
.drop-shadow { filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.2)); }
.backdrop-blur-md { backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }

.opacity-0 { opacity: 0; }
.scale-90 { transform: scale(0.9); }
.scale-110 { transform: scale(1.1); }
.pointer-events-none { pointer-events: none; }
.cursor-pointer { cursor: pointer; }
.select-none { user-select: none; }
.overflow-hidden { overflow: hidden; }
.focus\:outline-none:focus { outline: none; }

.transition-all { transition: all 0.2s ease; }
.transition-opacity { transition: opacity 0.25s ease; }
.transition-transform { transition: transform 0.15s ease; }
.transition-colors { transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease; }
.duration-150 { transition-duration: 150ms; }
.duration-200 { transition-duration: 200ms; }
.duration-300 { transition-duration: 300ms; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .45; }
}
.animate-pulse { animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite; }

@keyframes ping {
  75%, 100% { transform: scale(2); opacity: 0; }
}
.animate-ping { animation: ping 1.2s cubic-bezier(0, 0, 0.2, 1) infinite; }

/* Custom Toggle Switch (Self-Contained Replacement for Tailwind Peer Toggle) */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}
.toggle-track {
  width: 2.5rem;
  height: 1.5rem;
  background-color: #CBD5E1;
  border-radius: 9999px;
  position: relative;
  transition: background-color 0.2s ease;
}
.toggle-track::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 1.25rem;
  height: 1.25rem;
  background-color: #FFFFFF;
  border: 1px solid #CBD5E1;
  border-radius: 9999px;
  transition: transform 0.2s ease;
}
input:checked + .toggle-track {
  background-color: #299BCE;
}
input:checked + .toggle-track::after {
  transform: translateX(100%);
  border-color: #FFFFFF;
}

@media (min-width: 640px) {
  .sm\:block { display: block !important; }
  .sm\:py-5 { padding-top: 1.25rem; padding-bottom: 1.25rem; }
  .sm\:px-6 { padding-left: 1.5rem; padding-right: 1.5rem; }
  .sm\:px-4 { padding-left: 1rem; padding-right: 1rem; }
  .sm\:py-3 { padding-top: 0.75rem; padding-bottom: 0.75rem; }
  .sm\:p-3 { padding: 0.75rem; }
  .sm\:p-7 { padding: 1.75rem; }
  .sm\:gap-2 { gap: 0.5rem; }
  .sm\:w-3 { width: 0.75rem; }
  .sm\:h-3 { height: 0.75rem; }
  .sm\:w-5 { width: 1.25rem; }
  .sm\:h-5 { height: 1.25rem; }
  .sm\:w-6 { width: 1.5rem; }
  .sm\:h-6 { height: 1.5rem; }
  .sm\:w-8 { width: 2rem; }
  .sm\:h-8 { height: 2rem; }
  .sm\:w-10 { width: 2.5rem; }
  .sm\:h-10 { height: 2.5rem; }
  .sm\:w-\[18px\] { width: 18px; }
  .sm\:h-\[18px\] { height: 18px; }
  .sm\:text-\[11px\] { font-size: 11px; }
  .sm\:text-sm { font-size: 0.875rem; line-height: 1.25rem; }
  .sm\:text-base { font-size: 1rem; line-height: 1.5rem; }
  .sm\:text-3xl { font-size: 1.875rem; line-height: 2.25rem; }
  .sm\:text-4xl { font-size: 2.25rem; line-height: 2.5rem; }
  .sm\:text-5xl { font-size: 3rem; line-height: 1; }
}

/* Ambient background decorative soft blurs */
.ambient-orb {
  position: fixed;
  border-radius: 9999px;
  filter: blur(75px);
  opacity: 0.45;
  pointer-events: none;
  z-index: 0;
}

/* Frosted Glass HUD Pill */
.hud-glass {
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.92);
  box-shadow:
    0 10px 25px -5px rgba(15, 23, 42, 0.05),
    0 2px 6px -1px rgba(15, 23, 42, 0.03),
    inset 0 1px 0 0 rgba(255, 255, 255, 0.95);
}

/* Invisible 6x6 Grid Container */
.arena-wrapper {
  position: relative;
  width: min(88vw, 56vh, 456px);
  height: min(88vw, 56vh, 456px);
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: clamp(6px, 1.6vw, 11px);
  z-index: 10;
}

@media (min-height: 760px) and (min-width: 500px) {
  .arena-wrapper {
    width: min(86vw, 60vh, 468px);
    height: min(86vw, 60vh, 468px);
  }
}

/* Individual Cell — completely invisible when empty */
.grid-cell {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 16px;
  pointer-events: none;
}

/* Screen Shake on Hazard Tap */
@keyframes hazardShake {
  0%, 100% { transform: translate3d(0, 0, 0); }
  15% { transform: translate3d(-9px, 4px, 0); }
  30% { transform: translate3d(8px, -5px, 0); }
  45% { transform: translate3d(-7px, -3px, 0); }
  60% { transform: translate3d(6px, 4px, 0); }
  75% { transform: translate3d(-4px, 1px, 0); }
}

.shake-screen {
  animation: hazardShake 0.36s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

/* Tactile 3D CTA Button */
.btn-3d-primary {
  position: relative;
  background: linear-gradient(180deg, #299BCE 0%, #1B7CAE 100%);
  color: #FFFFFF;
  border: 1px solid #50B4E0;
  box-shadow:
    0 5px 0 0 #17638D,
    0 12px 20px -4px rgba(27, 124, 174, 0.38),
    inset 0 1px 0 0 rgba(255, 255, 255, 0.45);
  transform: translateY(-2px);
  transition: all 0.12s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.btn-3d-primary:hover {
  transform: translateY(-3.5px);
  box-shadow:
    0 6.5px 0 0 #17638D,
    0 15px 24px -4px rgba(27, 124, 174, 0.45),
    inset 0 1px 0 0 rgba(255, 255, 255, 0.55);
}
.btn-3d-primary:active {
  transform: translateY(2px);
  box-shadow:
    0 1px 0 0 #17638D,
    0 4px 8px -2px rgba(27, 124, 174, 0.3);
}

/* Secondary 3D Button */
.btn-3d-secondary {
  position: relative;
  background: linear-gradient(180deg, #FFFFFF 0%, #F1F5F9 100%);
  color: #1E293B;
  border: 1px solid #CBD5E1;
  box-shadow:
    0 4px 0 0 #CBD5E1,
    0 8px 15px -3px rgba(15, 23, 42, 0.08),
    inset 0 1px 0 0 #FFFFFF;
  transform: translateY(-2px);
  transition: all 0.12s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.btn-3d-secondary:hover {
  transform: translateY(-3px);
  box-shadow:
    0 5px 0 0 #CBD5E1,
    0 10px 18px -3px rgba(15, 23, 42, 0.12),
    inset 0 1px 0 0 #FFFFFF;
}
.btn-3d-secondary:active {
  transform: translateY(1.5px);
  box-shadow:
    0 0.5px 0 0 #CBD5E1,
    0 2px 5px -1px rgba(15, 23, 42, 0.08);
}

/* Heart / Shield Pulse */
@keyframes heartBreak {
  0% { transform: scale(1); }
  30% { transform: scale(1.35) rotate(-10deg); }
  60% { transform: scale(0.75) rotate(10deg); }
  100% { transform: scale(0.88); }
}
.life-lost-anim {
  animation: heartBreak 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* Subtle pulse on hazard tile to warn player */
@keyframes hazardPulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.08); }
}
.tile-hazard.tile-active {
  animation: hazardPulse 0.55s ease-in-out infinite;
}

#hazardFlashOverlay {
  background: radial-gradient(circle, rgba(221, 86, 109,0.08) 40%, rgba(200, 54, 86,0.38) 100%);
}
