:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #14141f;
  --bg-tertiary: #1e1e2e;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  --accent: #00d4ff;
  --accent-secondary: #00ff88;
  --danger: #ff4466;
  --focus-ring: #00d4ff;
  --focus-glow: rgba(0, 212, 255, 0.4);
  --radius-md: 12px;
  --radius-lg: 18px;
  --red: #ff4d6d;
  --black: #e8e8f0;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 600px;
  height: 600px;
  overflow: hidden;
  background: #000;
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

#app { width: 100%; height: 100%; position: relative; }

.screen {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
}

.screen.hidden { display: none; }
.hidden { display: none !important; }

.focusable {
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease, background 0.12s ease;
  border: 2px solid transparent;
  cursor: pointer;
  outline: none;
}

.focusable:focus {
  border-color: var(--focus-ring);
  box-shadow: 0 0 20px var(--focus-glow);
  transform: scale(1.03);
}

/* ---------- HOME ---------- */

.home-wrap {
  width: 100%;
  height: 100%;
  padding: 50px 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

.title {
  font-size: 88px;
  font-weight: 900;
  letter-spacing: 4px;
  color: var(--text-primary);
  text-shadow: 0 0 30px rgba(0, 212, 255, 0.6);
}

.title .dash {
  color: var(--accent);
  margin: 0 -4px;
}

.tagline {
  font-size: 20px;
  color: var(--text-secondary);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 16px;
}

.hi-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 36px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--bg-tertiary);
  margin-bottom: 20px;
}

.hi-label {
  font-size: 12px;
  color: var(--text-muted);
  letter-spacing: 3px;
}

.hi-value {
  font-size: 36px;
  font-weight: 800;
  color: var(--accent-secondary);
}

.menu {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 360px;
}

.menu-btn {
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 2px;
  padding: 22px 24px;
  border-radius: var(--radius-md);
  min-height: 88px;
  font-family: inherit;
  border: 2px solid transparent;
}

.menu-btn.primary {
  background: linear-gradient(135deg, #0094bf 0%, #00d4ff 100%);
  color: var(--bg-primary);
}

.menu-btn:focus {
  background: linear-gradient(135deg, #00b4e0 0%, #00ffff 100%);
  color: var(--bg-primary);
}

.menu-btn.primary:focus {
  background: linear-gradient(135deg, #00d4ff 0%, #00ff88 100%);
}

/* ---------- GAME ---------- */

.hud {
  display: flex;
  justify-content: space-between;
  padding: 18px 24px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--bg-tertiary);
}

.hud-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.hud-label {
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--text-muted);
}

.hud-value {
  font-size: 24px;
  font-weight: 800;
  color: var(--text-primary);
}

.table {
  flex: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.card-stack {
  position: relative;
  width: 360px;
  height: 280px;
}

.card-slot {
  position: absolute;
  top: 0;
  width: 180px;
  height: 260px;
}

.back-slot {
  left: 20px;
  transform: rotate(-6deg);
}

.front-slot {
  right: 20px;
  transform: rotate(4deg);
}

.card {
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #f8f8ff 0%, #e6e6f0 100%);
  border-radius: 14px;
  border: 2px solid #2a2a3e;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.05);
  position: relative;
  overflow: hidden;
  color: #1a1a2a;
}

.card.red { color: var(--red); }
.card.black { color: var(--black); }

.card-corner {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1;
}

.card-corner.top {
  top: 10px;
  left: 14px;
}

.card-corner.bottom {
  bottom: 10px;
  right: 14px;
  transform: rotate(180deg);
}

.card-rank {
  font-size: 30px;
  font-weight: 800;
  color: inherit;
}

.card-suit {
  font-size: 22px;
  color: inherit;
}

.card-center {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-suit-big {
  font-size: 90px;
  color: inherit;
}

.card-red { color: var(--red); }
.card-black { color: #1a1a2a; }

.card-back {
  background: linear-gradient(135deg, #00d4ff 0%, #003a55 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.back-pattern {
  position: absolute;
  inset: 8px;
  border-radius: 8px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  background-image:
    repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.08) 0 6px, transparent 6px 12px);
}

.back-label {
  position: relative;
  font-size: 80px;
  font-weight: 900;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

.card.deal {
  animation: deal 0.32s ease-out;
}

.card.flash-good {
  animation: flashGood 0.45s ease-out;
}

.card.flash-bad {
  animation: flashBad 0.45s ease-out;
}

@keyframes deal {
  0% { transform: translateY(-40px) rotate(-20deg); opacity: 0; }
  100% { transform: translateY(0) rotate(0); opacity: 1; }
}

@keyframes flashGood {
  0%, 100% { box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6); }
  50% { box-shadow: 0 0 40px var(--accent-secondary), 0 8px 24px rgba(0, 0, 0, 0.6); }
}

@keyframes flashBad {
  0%, 100% { box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6); }
  50% { box-shadow: 0 0 40px var(--danger), 0 8px 24px rgba(0, 0, 0, 0.6); }
}

.result-banner {
  position: absolute;
  top: 30px;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 28px;
  background: var(--bg-secondary);
  border-radius: 24px;
  border: 2px solid var(--accent-secondary);
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 3px;
  color: var(--accent-secondary);
}

.result-banner.bad {
  border-color: var(--danger);
  color: var(--danger);
}

.actions {
  display: flex;
  gap: 14px;
  padding: 16px 24px 24px;
}

.action-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-height: 96px;
  border-radius: var(--radius-lg);
  font-family: inherit;
  font-weight: 800;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 2px solid var(--bg-tertiary);
}

.action-btn .arrow {
  font-size: 28px;
  line-height: 1;
}

.action-btn .action-label {
  font-size: 20px;
  letter-spacing: 2px;
}

.action-btn.higher {
  border-color: rgba(0, 255, 136, 0.4);
}

.action-btn.higher:focus {
  background: linear-gradient(135deg, #00aa66 0%, #00ff88 100%);
  border-color: var(--accent-secondary);
  color: var(--bg-primary);
  box-shadow: 0 0 24px rgba(0, 255, 136, 0.5);
}

.action-btn.lower {
  border-color: rgba(255, 68, 102, 0.4);
}

.action-btn.lower:focus {
  background: linear-gradient(135deg, #c43050 0%, #ff4466 100%);
  border-color: var(--danger);
  color: var(--text-primary);
  box-shadow: 0 0 24px rgba(255, 68, 102, 0.5);
}

/* ---------- GAME OVER ---------- */

.over-wrap {
  width: 100%;
  height: 100%;
  padding: 50px 60px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 28px;
}

.over-label {
  font-size: 44px;
  font-weight: 900;
  letter-spacing: 6px;
  color: var(--danger);
  text-shadow: 0 0 20px rgba(255, 68, 102, 0.4);
}

.over-score {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 28px 60px;
  background: var(--bg-secondary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--bg-tertiary);
}

.over-score-num {
  font-size: 84px;
  font-weight: 900;
  color: var(--accent);
  line-height: 1;
}

.over-score-label {
  font-size: 14px;
  letter-spacing: 3px;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.over-best {
  padding: 8px 24px;
  background: var(--accent-secondary);
  color: var(--bg-primary);
  font-weight: 900;
  letter-spacing: 3px;
  border-radius: 20px;
  font-size: 16px;
}

.over-menu {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 360px;
  margin-top: 8px;
}

/* ---------- HOW TO ---------- */

.howto-wrap {
  width: 100%;
  height: 100%;
  padding: 40px 50px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.howto-title {
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 4px;
  color: var(--text-primary);
  text-align: center;
}

.howto-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  flex: 1;
}

.howto-row {
  display: flex;
  gap: 18px;
  align-items: center;
  padding: 14px 18px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--bg-tertiary);
}

.howto-num {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: var(--bg-primary);
  border-radius: 50%;
  font-weight: 800;
  font-size: 18px;
}

.howto-text {
  font-size: 17px;
  color: var(--text-primary);
  line-height: 1.4;
}
