/* TOFU BROS - CSS Design System */

:root {
  --color-bg: #1a1a2e;
  --color-panel: rgba(15, 15, 30, 0.85);
  --color-border: rgba(232, 93, 74, 0.4);
  --color-tofu-red: #E85D4A;
  --color-tofu-gold: #FFD700;
  --color-mario-blue: #5C94FC;
  --color-mario-green: #27AE60;
  --color-neon-cyan: #00f2fe;
  --color-neon-yellow: #fffb00;
  --color-neon-red: #ff3131;
  --color-text: #e0e6ed;
  --color-text-dim: #7f8c9d;
  --font-retro: 'Press Start 2P', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

body {
  background-color: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font-retro);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  display: flex;
  justify-content: center;
  align-items: center;
}

.font-pressstart { font-family: var(--font-retro); }

#crt-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: linear-gradient(rgba(18,16,16,0) 50%, rgba(0,0,0,0.25) 50%);
  background-size: 100% 4px;
  pointer-events: none;
  z-index: 9998;
  opacity: 0;
  transition: opacity 0.3s;
}
#crt-overlay.crt-active { opacity: 0.15; }

#crt-bezel {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  box-shadow: inset 0 0 80px rgba(0,0,0,0.6);
  pointer-events: none;
  z-index: 9999;
  opacity: 0;
}
#crt-bezel.crt-active { opacity: 1; }

#app-container {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 560px;
  height: 100vh;
  max-height: 720px;
  background: var(--color-panel);
  border: 2px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
}

#game-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  padding: 8px 12px;
  background: #000;
  border-bottom: 2px solid var(--color-tofu-red);
  gap: 4px;
}

.score-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 60px;
}

.score-label {
  font-size: 6px;
  color: var(--color-tofu-gold);
  margin-bottom: 2px;
}

.score-val {
  font-size: 8px;
  color: #fff;
  display: inline-block;
  transform-origin: center center;
}

.score-container.hud-spin-active .score-val {
  animation: hud-score-spin 0.45s linear infinite;
  color: var(--color-tofu-gold);
  text-shadow: 0 0 6px rgba(255, 215, 0, 0.8);
}

@keyframes hud-score-spin {
  0% { transform: scale(1) rotateY(0deg); }
  25% { transform: scale(1.35) rotateY(90deg); }
  50% { transform: scale(1.5) rotateY(180deg); }
  75% { transform: scale(1.35) rotateY(270deg); }
  100% { transform: scale(1) rotateY(360deg); }
}

#game-main {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #000;
  overflow: hidden;
}

#canvas-wrapper {
  position: relative;
  width: 100%;
  max-width: 512px;
}

#game-canvas {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#game-canvas:focus {
  outline: 2px solid rgba(232, 93, 74, 0.5);
  outline-offset: 2px;
}

#ui-overlay {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  pointer-events: none;
}

.ui-screen {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  display: none;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  background: rgba(0,0,0,0.75);
  pointer-events: all;
  padding: 16px;
  text-align: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.ui-screen.active { display: flex; }

.title-content { max-width: 90%; }

.game-title {
  font-size: clamp(18px, 5vw, 28px);
  color: var(--color-tofu-red);
  text-shadow: 3px 3px 0 #000;
  margin-bottom: 4px;
}

.title-sub { color: var(--color-tofu-gold); }

.title-tagline {
  font-size: 8px;
  color: var(--color-neon-cyan);
  margin-bottom: 16px;
}

.char-select-box {
  background: rgba(0,0,0,0.5);
  border: 2px solid var(--color-tofu-red);
  border-radius: 8px;
  padding: 12px;
  margin: 12px 0;
}

.char-select-label {
  font-size: 7px;
  color: var(--color-tofu-gold);
  margin-bottom: 8px;
}

.char-select-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 8px;
}

.btn-char-nav {
  background: var(--color-tofu-red);
  border: none;
  color: #fff;
  font-family: var(--font-retro);
  font-size: 10px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  border-radius: 4px;
}
.btn-char-nav:hover { background: #ff7a68; }

#char-preview {
  background: var(--color-mario-blue);
  border: 2px solid #fff;
  border-radius: 4px;
  image-rendering: pixelated;
}

.char-name { font-size: 9px; color: #fff; margin: 4px 0; }
.char-role { font-size: 7px; color: var(--color-neon-cyan); margin-bottom: 4px; }
.char-desc { font-size: 6px; color: var(--color-text-dim); line-height: 1.6; }

.blink { animation: blink 1s step-start infinite; }
@keyframes blink { 50% { opacity: 0; } }

.text-yellow { color: var(--color-neon-yellow); }
.text-cyan { color: var(--color-neon-cyan); }
.text-red { color: var(--color-neon-red); }
.text-green { color: var(--color-mario-green); }
.text-gray { color: var(--color-text-dim); }

.score-container-high {
  min-width: 72px;
}

.score-name {
  font-size: 6px;
  color: var(--color-tofu-gold);
  max-width: 72px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-box {
  margin: 10px 0 8px;
  padding: 8px 12px;
  border: 2px solid var(--color-tofu-gold);
  background: rgba(0, 0, 0, 0.45);
  max-width: 320px;
}

.ranking-status {
  font-size: 5px;
  color: var(--color-text-dim);
  margin-bottom: 4px;
}

.ranking-status.online {
  color: var(--color-mario-green);
}

.ranking-title {
  font-size: 7px;
  margin-bottom: 4px;
}

.ranking-legend {
  font-size: 5px;
  color: var(--color-text-dim);
  margin: -2px 0 4px;
  letter-spacing: 0.5px;
}

.ranking-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 6px;
  line-height: 1.9;
  color: #fff;
  text-align: left;
}

.ranking-char {
  font-weight: bold;
}

.highscore-entry {
  margin: 12px 0;
  padding: 10px;
  border: 2px dashed var(--color-tofu-gold);
  background: rgba(255, 215, 0, 0.08);
}

.highscore-entry.hidden {
  display: none;
}

.new-rank-label {
  font-size: 8px;
  margin-bottom: 8px;
}

.highscore-label {
  display: block;
  font-family: var(--font-retro);
  font-size: 7px;
  color: var(--color-neon-cyan);
  margin-bottom: 6px;
}

.highscore-input {
  font-family: var(--font-retro);
  font-size: 10px;
  padding: 8px 10px;
  width: min(200px, 80vw);
  text-align: center;
  text-transform: uppercase;
  background: #111;
  color: #fff;
  border: 2px solid var(--color-tofu-gold);
  margin-bottom: 8px;
}

.highscore-input:focus {
  outline: none;
  border-color: var(--color-neon-cyan);
  box-shadow: 0 0 8px rgba(0, 255, 255, 0.4);
}

.tips-heading {
  margin-top: 6px;
}

.instruction-box {
  font-size: 6px;
  color: var(--color-text-dim);
  margin: 12px 0;
  line-height: 2;
}

.screen-title-text {
  font-size: clamp(14px, 4vw, 20px);
  margin-bottom: 16px;
  line-height: 1.6;
}

.results-box {
  font-size: 8px;
  margin-bottom: 16px;
  line-height: 2;
}

.btn-retro {
  font-family: var(--font-retro);
  font-size: 8px;
  padding: 10px 20px;
  margin: 4px;
  background: var(--color-tofu-red);
  color: #fff;
  border: 2px solid #fff;
  cursor: pointer;
  transition: transform 0.1s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.btn-retro:hover { transform: scale(1.05); background: #ff7a68; }
.btn-secondary { background: #444; border-color: #888; }
.btn-secondary:hover { background: #666; }

#game-footer {
  background: #000;
  border-top: 2px solid var(--color-tofu-red);
  padding: 8px;
}

#status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 8px 8px;
}

.footer-brand { font-size: 6px; color: var(--color-text-dim); }

.icon-btn-settings {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
}

#mobile-controls {
  display: none;
  justify-content: space-between;
  align-items: center;
  padding: 0 8px;
}

.d-pad, .action-buttons { display: flex; gap: 8px; }

.control-btn {
  font-family: var(--font-retro);
  font-size: 10px;
  width: 56px;
  height: 56px;
  background: rgba(255,255,255,0.1);
  border: 2px solid rgba(255,255,255,0.3);
  color: #fff;
  border-radius: 8px;
  cursor: pointer;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
.control-btn:active { background: rgba(232,93,74,0.5); }

.btn-action-jump {
  width: 80px;
  background: rgba(232,93,74,0.3);
  border-color: var(--color-tofu-red);
}

.modal-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: rgba(0,0,0,0.8);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 10000;
}
.modal-overlay.active { display: flex; }

.modal-content {
  background: var(--color-panel);
  border: 2px solid var(--color-tofu-red);
  padding: 24px;
  border-radius: 8px;
  min-width: 280px;
}

.modal-title { font-size: 12px; margin-bottom: 16px; text-align: center; }

.setting-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  font-size: 7px;
}

.range-wrapper { display: flex; align-items: center; gap: 8px; }
#vol-range { width: 100px; }

.switch { position: relative; display: inline-block; width: 40px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: #444; border-radius: 22px; transition: 0.3s;
}
.slider:before {
  position: absolute; content: "";
  height: 16px; width: 16px; left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%; transition: 0.3s;
}
input:checked + .slider { background: var(--color-tofu-red); }
input:checked + .slider:before { transform: translateX(18px); }

.cookie-consent {
  z-index: 10001;
}

.cookie-consent-content {
  max-width: 420px;
  width: min(92vw, 420px);
}

.cookie-consent-body {
  font-size: 7px;
  line-height: 1.9;
  color: #ddd;
  margin-bottom: 16px;
  text-align: left;
}

.cookie-consent-body strong {
  color: var(--color-tofu-gold);
}

.cookie-consent-list {
  margin: 10px 0 10px 16px;
  padding: 0;
}

.cookie-consent-list li {
  margin-bottom: 4px;
}

.cookie-consent-note {
  color: var(--color-text-dim);
  font-size: 6px;
}

.cookie-consent-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.btn-small {
  font-size: 6px;
  padding: 8px 12px;
}

@media (max-width: 600px), (hover: none) {
  #mobile-controls { display: flex; }
  #game-header .score-container { min-width: 48px; }
  .score-label { font-size: 5px; }
  .score-val { font-size: 7px; }
}

@media (min-width: 601px) {
  body { background: radial-gradient(ellipse at center, #2a2a4e 0%, #1a1a2e 70%); }
}
