/* ANGRY TURDS — 90s/early-2000s CRT arcade vibe */
:root {
  --slime: #7cd33a;
  --slime-bright: #b6ff5b;
  --slime-deep: #2c6a1a;
  --brown: #6e3c14;
  --brown-light: #9a5a23;
  --brown-deep: #3a1f08;
  --crt-bg: #0c1209;
  --ink: #f6ffd6;
  --ink-dim: #c3d692;
  --red: #d8362a;
  --yellow: #ffd23a;
  --pink: #ff6ec7;
  --cyan: #2bd6e6;
  --panel: rgba(8, 16, 4, 0.78);
  --panel-border: #5a8a22;
  --font-disp: 'Press Start 2P', 'Courier New', monospace;
  --font-body: 'VT323', 'Courier New', monospace;
}

* {
  box-sizing: border-box;
}
html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #050803;
  color: var(--ink);
  font-family: var(--font-body);
  overflow: hidden;
  cursor: crosshair;
}
#app {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  /* Subtle moving slime grime */
  background:
    radial-gradient(ellipse at 50% 50%, #0c1209 0%, #050803 70%),
    repeating-linear-gradient(45deg, #061107 0 6px, #050a04 6px 12px);
}

#crt {
  position: relative;
  width: min(96vw, calc(96vh * 16 / 9));
  aspect-ratio: 16 / 9;
  padding: 20px 24px 28px;
  border-radius: 24px;
  background:
    linear-gradient(180deg, #1a1f10 0%, #0b1106 100%);
  box-shadow:
    inset 0 0 0 4px #2a3318,
    inset 0 0 0 8px #0d1306,
    0 0 40px rgba(124, 211, 58, 0.18),
    0 30px 60px rgba(0, 0, 0, 0.7);
}

#stage {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 12px;
  overflow: hidden;
  background: #000;
  box-shadow:
    inset 0 0 0 2px #1d2710,
    inset 0 0 40px rgba(0, 0, 0, 0.6);
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
}

#scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, 0) 0,
    rgba(0, 0, 0, 0) 2px,
    rgba(0, 0, 0, 0.28) 3px,
    rgba(0, 0, 0, 0.28) 3px
  );
  mix-blend-mode: multiply;
  animation: flicker 7s infinite steps(60);
}
#vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse at center, rgba(0, 0, 0, 0) 55%, rgba(0, 0, 0, 0.55) 100%),
    radial-gradient(circle at 20% 0%, rgba(124, 211, 58, 0.08), transparent 40%);
}
#rotate-screen {
  display: none;
}
@keyframes flicker {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 0.95; }
}

@keyframes phoneWiggle {
  0%, 100% { transform: rotate(0deg); }
  35% { transform: rotate(90deg); }
  70% { transform: rotate(90deg); }
}

/* HUD */
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 12px 14px;
  font-family: var(--font-disp);
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--ink);
  text-shadow: 0 2px 0 #000, 0 0 6px rgba(0,0,0,0.6);
}
.hud-row {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
}
.hud-row.top { align-items: flex-start; }
.hud-row.bottom { align-items: flex-end; }

.center-stack {
  display: grid;
  gap: 6px;
  justify-items: center;
}
.match {
  background: rgba(8, 16, 4, 0.86);
  border: 2px solid var(--panel-border);
  border-radius: 3px;
  color: var(--cyan);
  padding: 5px 8px;
  font-size: 8px;
  box-shadow: 0 0 0 2px #000, inset 0 0 0 1px #1c3a0a;
  white-space: nowrap;
}

.hp {
  background: var(--panel);
  border: 2px solid var(--panel-border);
  border-radius: 4px;
  padding: 6px 8px;
  min-width: 200px;
  box-shadow: 0 0 0 2px #000, inset 0 0 0 1px #2a4612;
}
.hp .name { font-size: 9px; color: var(--slime-bright); margin-bottom: 4px; }
.hp-right .name { text-align: right; color: var(--pink); }
.hp .bar {
  height: 10px;
  background: #1c2a0d;
  border: 1px solid #000;
  position: relative;
  overflow: hidden;
}
.hp .fill {
  position: absolute;
  inset: 0;
  width: 100%;
  background: linear-gradient(180deg, #b6ff5b, #4ea51b 50%, #2c6a1a);
  border-right: 2px solid #000;
  transition: width 160ms steps(8);
}
.hp-right .fill {
  background: linear-gradient(180deg, #ff9ad1, #d8362a 50%, #7a1a14);
}

.badge {
  background: var(--yellow);
  color: #2a1500;
  padding: 6px 10px;
  border: 2px solid #000;
  border-radius: 3px;
  box-shadow: 0 2px 0 #000, 0 0 0 2px #b08a14 inset;
  animation: badgePulse 1.4s infinite steps(2);
}
@keyframes badgePulse {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

.wind, .meter {
  background: var(--panel);
  border: 2px solid var(--panel-border);
  padding: 6px 10px;
  border-radius: 3px;
  font-size: 10px;
  color: var(--ink);
  letter-spacing: 1px;
}
.meter { color: var(--yellow); }
.hud-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  pointer-events: auto;
}
.btn {
  pointer-events: auto;
  background: var(--panel);
  border: 2px solid var(--panel-border);
  color: var(--ink);
  font-family: var(--font-disp);
  font-size: 9px;
  padding: 6px 10px;
  cursor: pointer;
  border-radius: 3px;
  letter-spacing: 1px;
  touch-action: manipulation;
}
.btn:hover { background: #16290a; color: var(--slime-bright); }
.btn[aria-pressed="true"] { color: var(--red); }

/* Overlays */
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: auto;
  background: radial-gradient(ellipse at center, rgba(7, 14, 4, 0.7), rgba(2, 5, 1, 0.95));
  z-index: 10;
}
.overlay.hidden { display: none; }

.title-card, .end-card {
  text-align: center;
  padding: 20px 28px;
  border: 4px solid var(--slime-deep);
  background:
    linear-gradient(180deg, #14210a, #0a1305);
  box-shadow:
    0 0 0 2px #000,
    0 0 0 6px #1f3a0e,
    0 0 40px rgba(124, 211, 58, 0.25);
  border-radius: 6px;
  width: min(760px, 88%);
  max-width: 88%;
}
.game-title {
  font-family: var(--font-disp);
  font-size: clamp(28px, 6vw, 64px);
  line-height: 1;
  margin: 0 0 8px;
  color: var(--brown-light);
  text-shadow:
    2px 2px 0 var(--brown-deep),
    4px 4px 0 #000,
    0 0 12px rgba(154, 90, 35, 0.4);
  letter-spacing: 2px;
}
.tagline {
  font-family: var(--font-body);
  font-size: clamp(16px, 2.4vw, 22px);
  color: var(--slime-bright);
  margin: 0 0 14px;
  letter-spacing: 1px;
}
.how p {
  font-family: var(--font-body);
  font-size: clamp(13px, 1.8vw, 18px);
  color: var(--ink-dim);
  margin: 4px 0;
}
.menu-grid {
  display: grid;
  grid-template-columns: minmax(240px, 560px);
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
}
.menu-panel {
  border: 2px solid var(--panel-border);
  background: rgba(3, 8, 2, 0.72);
  box-shadow: inset 0 0 0 1px #17370b, 0 0 0 2px #000;
  padding: 10px;
  border-radius: 4px;
}
.menu-columns {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 14px;
  align-items: stretch;
}
.menu-column {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.menu-column-start {
  justify-content: space-between;
}
.menu-panel h2 {
  margin: 0 0 8px;
  font-family: var(--font-disp);
  font-size: 10px;
  color: var(--cyan);
  letter-spacing: 1px;
}
.mode-btn,
.player-btn {
  display: block;
  width: 100%;
  min-height: 38px;
  margin: 6px 0;
  border: 2px solid #000;
  border-radius: 3px;
  background: #16290a;
  color: var(--ink);
  font-family: var(--font-disp);
  font-size: 9px;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: inset 0 0 0 2px #2b5315;
  touch-action: manipulation;
}
.mode-btn.active,
.mode-btn:hover,
.player-btn.active,
.player-btn:hover {
  background: var(--yellow);
  color: #2a1500;
  box-shadow: 0 3px 0 #000, inset 0 0 0 2px #b08a14;
}
.menu-subhead {
  margin-top: 12px !important;
}
.mode-desc {
  min-height: 20px;
  margin: 10px 0 0;
  color: var(--slime-bright);
  font-family: var(--font-body);
  font-size: 18px;
}
.leaderboard {
  margin: 0;
  padding-left: 26px;
  text-align: left;
  font-family: var(--font-body);
  font-size: 18px;
  color: var(--ink-dim);
  line-height: 1.15;
}
.leaderboard li {
  margin: 4px 0;
}
.btn-big {
  margin-top: 16px;
  font-family: var(--font-disp);
  font-size: clamp(10px, 1.4vw, 14px);
  background: var(--yellow);
  color: #2a1500;
  padding: 12px 22px;
  border: 3px solid #000;
  border-radius: 4px;
  box-shadow: 0 4px 0 #000, inset 0 0 0 2px #b08a14;
  cursor: pointer;
  letter-spacing: 2px;
  transition: transform 80ms;
  touch-action: manipulation;
}
.btn-big:hover { background: #ffe85c; }
.btn-big:active { transform: translateY(3px); box-shadow: 0 1px 0 #000, inset 0 0 0 2px #b08a14; }
.btn-menu {
  display: block;
  margin: 12px auto 0;
  min-height: 38px;
  padding: 9px 16px;
  border: 2px solid var(--panel-border);
  border-radius: 3px;
  background: rgba(8, 16, 4, 0.86);
  color: var(--ink);
  font-family: var(--font-disp);
  font-size: 10px;
  letter-spacing: 1px;
  cursor: pointer;
  touch-action: manipulation;
}
.btn-menu:hover {
  color: var(--slime-bright);
  background: #16290a;
}

.copyleft {
  margin-top: 18px;
  font-family: var(--font-disp);
  font-size: 8px;
  color: #6c8a3a;
  letter-spacing: 1px;
}

#end-title {
  font-family: var(--font-disp);
  font-size: clamp(24px, 5vw, 48px);
  margin: 0 0 8px;
  color: var(--yellow);
  text-shadow: 3px 3px 0 #000;
}
#end-sub {
  font-family: var(--font-body);
  font-size: clamp(16px, 2.4vw, 22px);
  color: var(--slime-bright);
  margin: 0;
}

/* Small screens */
@media (max-width: 640px) {
  #crt { padding: 10px 12px 16px; border-radius: 14px; }
  .hp { min-width: 120px; }
  .hud-row { gap: 4px; }
  .center-stack { gap: 3px; }
  .match { font-size: 6px; padding: 3px 4px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; }
  .badge { font-size: 8px; padding: 4px 6px; }
  .wind, .meter, .btn { font-size: 8px; padding: 9px 8px; min-height: 34px; }
  .hud-actions { gap: 4px; }
  .title-card, .end-card { width: 94%; max-width: 94%; padding: 12px; }
  .menu-grid { grid-template-columns: 1fr; gap: 8px; margin-top: 8px; }
  .menu-panel { padding: 8px; }
  .menu-columns { grid-template-columns: 1fr; gap: 8px; }
  .mode-btn, .player-btn { min-height: 40px; font-size: 8px; margin: 5px 0; }
  .leaderboard, .mode-desc { font-size: 16px; }
  .copyleft { margin-top: 10px; }
}

@media (max-width: 900px) and (orientation: landscape) {
  #crt {
    width: 100vw;
    height: 100dvh;
    aspect-ratio: auto;
    padding: 6px 8px 10px;
    border-radius: 10px;
  }
  #stage {
    height: 100%;
  }
  #hud {
    padding: 7px 8px;
  }
  .hp {
    min-width: 126px;
  }
  .match {
    max-width: 230px;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .wind, .meter, .btn {
    min-height: 36px;
    padding: 9px 8px;
  }
  .title-card, .end-card {
    width: min(800px, 96%);
    max-width: 96%;
    max-height: calc(100dvh - 16px);
    padding: 6px 12px;
    overflow: hidden;
  }
  .game-title {
    font-size: clamp(18px, 7.2vh, 28px);
    margin-bottom: 2px;
  }
  .tagline {
    display: none;
  }
  .how {
    display: none;
  }
  .how p {
    margin: 2px 0;
  }
  .menu-grid {
    margin-top: 4px;
    gap: 6px;
    grid-template-columns: minmax(300px, 740px);
  }
  .menu-panel {
    padding: 5px;
  }
  .menu-columns {
    grid-template-columns: minmax(0, 1.1fr) minmax(190px, 0.9fr);
    gap: 8px;
  }
  .menu-panel h2 {
    margin-bottom: 3px;
    font-size: 7px;
  }
  .mode-btn,
  .player-btn {
    min-height: 32px;
    margin: 2px 0 4px;
    font-size: 6px;
  }
  .menu-subhead {
    margin-top: 4px !important;
  }
  .leaderboard {
    font-size: 15px;
    line-height: 1;
  }
  .mode-desc {
    display: block;
    min-height: 0;
    margin: 4px 0;
    font-size: 13px;
    line-height: 1;
  }
  .btn-big {
    width: 100%;
    margin-top: 4px;
    min-height: 44px;
    padding: 9px 10px;
    font-size: 10px;
  }
  .copyleft {
    display: none;
  }
}

@media (max-width: 900px) and (orientation: portrait) {
  #app {
    place-items: center;
  }
  #crt {
    width: 100vw;
    height: 100dvh;
    aspect-ratio: auto;
    padding: 8px;
    border-radius: 0;
  }
  #stage {
    height: 100%;
  }
  #rotate-screen {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: grid;
    place-items: center;
    padding: 24px;
    pointer-events: auto;
    background:
      radial-gradient(ellipse at center, rgba(12, 26, 5, 0.94), rgba(2, 5, 1, 0.99)),
      repeating-linear-gradient(to bottom, rgba(0,0,0,0), rgba(0,0,0,0) 2px, rgba(0,0,0,0.28) 3px);
  }
  .rotate-card {
    width: min(330px, 92vw);
    text-align: center;
    border: 4px solid var(--slime-deep);
    border-radius: 8px;
    background: linear-gradient(180deg, #14210a, #0a1305);
    box-shadow:
      0 0 0 2px #000,
      0 0 0 6px #1f3a0e,
      0 0 36px rgba(124, 211, 58, 0.24);
    padding: 28px 20px;
  }
  .phone-icon {
    width: 86px;
    height: 126px;
    display: grid;
    place-items: center;
    margin: 0 auto 18px;
    border: 5px solid var(--yellow);
    border-radius: 14px;
    color: transparent;
    box-shadow: inset 0 0 0 4px #000, 0 0 18px rgba(255, 210, 58, 0.22);
    animation: phoneWiggle 2.2s infinite steps(2);
  }
  .rotate-card h2 {
    margin: 0 0 12px;
    font-family: var(--font-disp);
    color: var(--yellow);
    font-size: 20px;
    line-height: 1.2;
    text-shadow: 3px 3px 0 #000;
  }
  .rotate-card p {
    margin: 8px 0;
    font-family: var(--font-body);
    color: var(--ink);
    font-size: 22px;
    line-height: 1.05;
  }
  .rotate-card .rotate-sub {
    color: var(--slime-bright);
    font-size: 18px;
  }
}
