:root {
  --ink: #181c20;
  --muted: #5b6673;
  --surface: #ffffff;
  --surface-alt: #f3f6f9;
  --border: #dfe6ee;
  --sky: #63c5f2;
  --green: #58cc02;
  --green-lip: #46a302;
  --yellow: #ffd43b;
  --yellow-lip: #e6b400;
  --blue: #1d9bf0;
  --red: #f03e3e;
  --teal: #0ca678;
}

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

input {
  user-select: text;
  -webkit-user-select: text;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #12161c;
  font-family: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  touch-action: none;
}

#app {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#game-shell {
  position: relative;
  width: min(100vw, calc(100vh * 420 / 720));
  height: min(100vh, calc(100vw * 720 / 420));
  max-width: 468px;
  max-height: 802px;
  overflow: hidden;
  border-radius: 8px;
  border: 3px solid #262d36;
  background: var(--sky);
}

@media (max-width: 520px) {
  #game-shell {
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    border-radius: 0;
    border: none;
  }
}

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

/* Minimal Flat Vector Top Controls */
#top-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 30;
  display: flex;
  gap: 6px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  border: 2px solid var(--ink);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.08s ease, opacity 0.15s ease;
}

.icon-btn.lang-btn {
  width: auto;
  padding: 0 9px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: 0.4px;
}

.icon-btn:active {
  transform: scale(0.93);
}

.icon-btn.muted {
  background: #e2e8f0;
  opacity: 0.55;
}

.ui-svg {
  width: 18px;
  height: 18px;
  display: block;
}

.inline-svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  display: block;
}

.heart-svg {
  width: 14px;
  height: 14px;
  color: #f03e3e;
  margin-top: 2px;
}

.mini-identicon {
  width: 20px;
  height: 20px;
  border-radius: 3px;
  overflow: hidden;
  border: 1.5px solid var(--ink);
  display: inline-flex;
  flex-shrink: 0;
}

/* Airy Open-Sky Start Screen */
.start-screen {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 76px 26px 102px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.start-screen.visible {
  opacity: 1;
  pointer-events: auto;
}

.start-top {
  text-align: center;
}

.hero-title {
  font-size: 38px;
  font-weight: 800;
  letter-spacing: -0.8px;
  line-height: 1.08;
  color: #ffffff;
  -webkit-text-stroke: 2.5px var(--ink);
  paint-order: stroke fill;
  margin-bottom: 10px;
}

.x-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  background: var(--ink);
  color: #ffffff;
  -webkit-text-stroke: 0;
  width: 42px;
  height: 42px;
  border-radius: 6px;
  border: 2.5px solid #ffffff;
  margin: 0 3px 4px;
}

.x-logo-svg {
  width: 24px;
  height: 24px;
  display: block;
}

.hero-sub {
  display: inline-block;
  background: rgba(24, 28, 32, 0.92);
  color: var(--yellow);
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: 0.2px;
  padding: 6px 12px;
  border-radius: 5px;
}

.start-bottom {
  width: 100%;
  max-width: 280px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.best-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: #ffffff;
  border: 2px solid var(--ink);
  border-radius: 5px;
  padding: 5px 11px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
}

.tap-hint {
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.86);
  padding: 4px 10px;
  border-radius: 4px;
}

/* Crisp Sharp-Corner Flat Buttons */
.flat-btn {
  width: 100%;
  padding: 13px 14px;
  border-radius: 6px;
  border: 2.5px solid var(--ink);
  font-family: inherit;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.3px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: transform 0.08s ease;
}

.flat-btn:active {
  transform: translateY(2px);
}

.btn-hero {
  padding: 15px 18px;
  font-size: 16px;
}

.btn-green {
  background: var(--green);
  color: #ffffff;
  border-bottom-width: 5px;
  border-bottom-color: var(--green-lip);
}

.btn-yellow {
  background: var(--yellow);
  color: var(--ink);
  font-size: 13px;
  padding: 10px 8px;
  border-bottom-width: 4px;
  border-bottom-color: var(--yellow-lip);
}

.btn-black {
  background: var(--ink);
  color: #ffffff;
  font-size: 13px;
  padding: 10px 8px;
  border-bottom-width: 4px;
  border-bottom-color: #000000;
}

.hidden {
  display: none !important;
}

/* Overlays */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 25;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(18, 22, 28, 0.48);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.flat-card {
  width: 100%;
  max-width: 356px;
  background: var(--surface);
  border: 2.5px solid var(--ink);
  border-radius: 8px;
  padding: 18px 16px 16px;
  text-align: center;
  animation: flatPop 0.18s ease-out;
}

@keyframes flatPop {
  from { transform: translateY(8px) scale(0.97); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.cause-pill {
  display: inline-block;
  background: #ffe3e3;
  color: #c92a2a;
  font-size: 11px;
  font-weight: 800;
  padding: 4px 10px;
  border-radius: 4px;
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.cause-pill.win {
  background: #fff3bf;
  color: #b45309;
}

.dota-title {
  font-size: 19px;
  font-weight: 800;
  line-height: 1.25;
  margin-bottom: 5px;
  color: var(--ink);
}

.roast-copy {
  font-size: 12.5px;
  line-height: 1.42;
  color: var(--muted);
  margin-bottom: 12px;
}

/* Single-Bar Score Summary */
.score-bar {
  display: flex;
  align-items: stretch;
  background: var(--surface-alt);
  border: 2px solid var(--ink);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 10px;
}

.score-main {
  flex: 1;
  background: var(--ink);
  color: var(--yellow);
  padding: 11px 10px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 2px;
}

.score-lbl {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.7px;
  opacity: 0.75;
}

.score-big {
  font-size: 27px;
  font-weight: 800;
  line-height: 1.1;
}

.score-divider {
  width: 2px;
  background: var(--ink);
}

.score-meta {
  flex: 1.18;
  padding: 9px 11px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 600;
}

.meta-row strong {
  color: var(--ink);
  font-weight: 800;
}

.meta-row .rank-txt {
  color: var(--teal);
  font-size: 11px;
}

/* Optional Opt-In Handle Box (Always Skippable) */
.optin-box {
  background: #f8fafc;
  border: 1.5px solid #cbd5e1;
  border-radius: 6px;
  padding: 8px 10px;
  margin-bottom: 10px;
  text-align: left;
}

.optin-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 6px;
}

.optin-row {
  display: flex;
  gap: 5px;
}

.optin-row input {
  flex: 1;
  min-width: 0;
  height: 32px;
  padding: 0 8px;
  border: 1.5px solid var(--ink);
  border-radius: 4px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  color: var(--ink);
  background: #ffffff;
}

.optin-save, .optin-skip {
  height: 32px;
  padding: 0 10px;
  border-radius: 4px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 800;
  cursor: pointer;
}

.optin-save {
  background: var(--blue);
  color: #ffffff;
  border: 1.5px solid var(--ink);
}

.optin-skip {
  background: #e2e8f0;
  color: var(--muted);
  border: 1.5px solid #cbd5e1;
}

.mutuals-line {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  background: #fff9db;
  border-radius: 6px;
  padding: 7px 9px;
  margin-bottom: 12px;
  text-align: left;
}

.mutuals-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.mutual-tag {
  background: #ffffff;
  border: 1.5px solid #ffd43b;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 800;
  color: var(--ink);
}

.action-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.action-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* Leaderboard Modal */
.lb-card {
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  padding: 16px;
}

.lb-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.lb-title {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.3px;
}

.lb-close {
  width: 30px;
  height: 30px;
  border-radius: 5px;
  border: 2px solid var(--ink);
  background: var(--surface-alt);
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.lb-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  margin-bottom: 8px;
}

.lb-tab {
  padding: 8px;
  border-radius: 5px;
  border: 2px solid var(--ink);
  background: var(--surface-alt);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 800;
  color: var(--muted);
  cursor: pointer;
}

.lb-tab.active {
  background: var(--ink);
  color: var(--yellow);
}

.lb-stats {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 8px;
}

.lb-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 340px;
  padding-right: 2px;
}

.lb-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  background: var(--surface-alt);
  border: 1.5px solid var(--border);
  border-radius: 5px;
  text-align: left;
}

.lb-row.me {
  background: #fff9db;
  border-color: var(--ink);
}

.lb-rank {
  width: 24px;
  font-size: 12px;
  font-weight: 800;
  color: var(--muted);
  text-align: center;
  flex-shrink: 0;
}

.lb-row:nth-child(1) .lb-rank { color: #d97706; }
.lb-row:nth-child(2) .lb-rank { color: #475569; }
.lb-row:nth-child(3) .lb-rank { color: #b45309; }

.lb-avatar {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  border: 1.5px solid var(--ink);
  overflow: hidden;
  flex-shrink: 0;
}

.lb-info {
  flex: 1;
  min-width: 0;
}

.lb-handle {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lb-sub {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
}

.lb-score {
  font-size: 13.5px;
  font-weight: 800;
  color: var(--ink);
  flex-shrink: 0;
}

.lb-me {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 2px dashed var(--border);
}

.flat-toast {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  background: var(--ink);
  color: var(--yellow);
  border-radius: 5px;
  padding: 8px 14px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
  max-width: 90%;
  overflow: hidden;
  text-overflow: ellipsis;
}
