@font-face {
  font-family: 'Rajdhani';
  src: url('../vendor/fonts/rajdhani-500.woff2') format('woff2');
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: 'Rajdhani';
  src: url('../vendor/fonts/rajdhani-600.woff2') format('woff2');
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: 'Rajdhani';
  src: url('../vendor/fonts/rajdhani-700.woff2') format('woff2');
  font-weight: 700;
  font-display: swap;
}

:root {
  --bg: #05070c;
  --text: #e8eef4;
  --dim: #8b98a8;
  --dimmer: #5c6774;
  --amber: #ffb02e;
  --amber-hot: #ffc65c;
  --cyan: #35e0d8;
  --red: #ff4d4d;
  --green: #3ddc84;
  --blue: #4d9bff;
  --panel: rgba(13, 17, 23, 0.88);
  --panel-border: rgba(255, 255, 255, 0.08);
  --font-display: 'Rajdhani', system-ui, sans-serif;
  --font-body: system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  --clip: polygon(14px 0, 100% 0, 100% calc(100% - 14px), calc(100% - 14px) 100%, 0 100%, 0 14px);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#app {
  position: fixed;
  inset: 0;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

#vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: radial-gradient(ellipse at center, transparent 42%, rgba(120, 0, 0, 0.55) 100%);
  z-index: 5;
  transition: opacity 0.25s linear;
}

#grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 6;
  opacity: 0.5;
  background-image: repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.014) 0 1px, transparent 1px 3px);
  mix-blend-mode: overlay;
}

#popups {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 30;
  overflow: hidden;
}

.popup {
  position: fixed;
  left: 0;
  top: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 20px;
  letter-spacing: 1px;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8), 0 0 18px rgba(0, 0, 0, 0.5);
  white-space: nowrap;
  will-change: transform, opacity;
}
.popup--gold { color: var(--amber-hot); text-shadow: 0 2px 8px rgba(0,0,0,.8), 0 0 16px rgba(255, 176, 46, 0.45); }
.popup--bad { color: var(--red); }
.popup--heal { color: var(--green); }
.popup--big {
  font-size: 30px;
  letter-spacing: 3px;
  color: var(--amber);
  text-shadow: 0 3px 12px rgba(0, 0, 0, 0.85), 0 0 24px rgba(255, 176, 46, 0.5);
}

.damage-indicator {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  border-top: 3px solid rgba(255, 77, 77, 0.9);
  pointer-events: none;
  animation: dmg-fade 0.7s ease-out forwards;
}
@keyframes dmg-fade {
  0% { opacity: 0.95; }
  100% { opacity: 0; }
}

#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 20;
}
#hud .hud-top {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  left: calc(env(safe-area-inset-left, 0px) + 18px);
  right: calc(env(safe-area-inset-right, 0px) + 112px);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.hud-hp {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 200px;
}
.hud-label {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 3px;
  color: var(--dim);
}
.hp-track {
  width: min(240px, 24vw);
  height: 13px;
  background: rgba(8, 10, 14, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.12);
  clip-path: polygon(6px 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
  overflow: hidden;
}
.hp-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #1f8f88, var(--cyan));
  transition: width 0.12s linear;
}
.hp-fill.low {
  background: linear-gradient(90deg, #8f1f1f, var(--red));
  animation: hp-pulse 0.9s ease-in-out infinite;
}
@keyframes hp-pulse {
  50% { opacity: 0.55; }
}
.hud-center {
  display: flex;
  align-items: baseline;
  gap: 14px;
  font-family: var(--font-display);
}
.hud-wave {
  font-weight: 700;
  font-size: 22px;
  letter-spacing: 4px;
  color: var(--text);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.7);
}
.hud-sub {
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 2px;
  color: var(--dim);
}
.hud-timer {
  font-family: var(--font-mono);
  color: var(--dim);
}
.hud-score {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.score-value {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 1px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.7);
}
.combo {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 1px;
  color: var(--amber);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.15s, transform 0.15s;
}
.combo.on {
  opacity: 1;
  transform: none;
}
.hud-buttons {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 14px);
  right: calc(env(safe-area-inset-right, 0px) + 18px);
  display: flex;
  gap: 8px;
  pointer-events: auto;
}
.icon-btn {
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(10, 14, 20, 0.66);
  color: var(--text);
  cursor: pointer;
  padding: 8px;
  clip-path: var(--clip);
}
.icon-btn svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}
.icon-btn .icon-off { display: none; }
.icon-btn.muted .icon-off { display: block; }
.icon-btn.muted .icon-on { display: none; }
.icon-btn:hover { border-color: var(--amber); color: var(--amber-hot); }

#crosshair {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 22;
  pointer-events: none;
  will-change: transform;
}
.crosshair-ring {
  position: absolute;
  left: 0;
  top: 0;
  width: 52px;
  height: 52px;
  margin: -26px 0 0 -26px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, var(--cyan) var(--dash, 360deg), rgba(255, 255, 255, 0.12) 0);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4.2px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 5px), #000 calc(100% - 4.2px));
  opacity: 0.9;
}
.crosshair-ring.overcharge {
  background: conic-gradient(from 0deg, var(--amber) var(--dash, 360deg), rgba(255, 255, 255, 0.14) 0);
}
.crosshair-dot {
  position: absolute;
  left: -2.5px;
  top: -2.5px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 8px rgba(53, 224, 216, 0.8);
}
.crosshair-tick {
  position: absolute;
  background: rgba(255, 255, 255, 0.6);
}
.crosshair-tick--n { left: -1px; top: -20px; width: 2px; height: 9px; }
.crosshair-tick--s { left: -1px; top: 11px; width: 2px; height: 9px; }
.crosshair-tick--e { left: 11px; top: -1px; width: 9px; height: 2px; }
.crosshair-tick--w { left: -20px; top: -1px; width: 9px; height: 2px; }

.hint {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 88px);
  transform: translateX(-50%);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 2px;
  color: var(--text);
  background: rgba(8, 11, 16, 0.76);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 8px 18px;
  clip-path: var(--clip);
  opacity: 0;
  transition: opacity 0.3s;
  white-space: nowrap;
}
.hint.in { opacity: 1; }

.banner {
  position: absolute;
  left: 0;
  right: 0;
  top: 26%;
  text-align: center;
  pointer-events: none;
}
.banner-main {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(30px, 5vw, 54px);
  letter-spacing: 10px;
  text-transform: uppercase;
  color: var(--text);
  text-shadow: 0 4px 22px rgba(0, 0, 0, 0.85), 0 0 40px rgba(255, 176, 46, 0.25);
}
.banner-sub {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 6px;
  color: var(--amber);
  margin-top: 4px;
}
.banner.in .banner-main {
  animation: banner-in 0.4s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
.banner.in .banner-sub {
  animation: banner-in 0.5s 0.06s cubic-bezier(0.2, 1.4, 0.4, 1) both;
}
@keyframes banner-in {
  from { opacity: 0; transform: translateY(14px) scale(1.08); letter-spacing: 22px; }
  to { opacity: 1; transform: none; }
}

.screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

#screen-menu {
  background:
    linear-gradient(100deg, rgba(4, 6, 10, 0.94) 0%, rgba(4, 6, 10, 0.72) 38%, rgba(4, 6, 10, 0.28) 62%, rgba(4, 6, 10, 0.78) 100%);
}
.menu-grid {
  display: grid;
  grid-template-columns: minmax(320px, 1.15fr) minmax(300px, 0.85fr);
  gap: clamp(24px, 4vw, 64px);
  width: min(1160px, calc(100% - 64px));
  max-height: calc(100% - 48px);
  align-items: center;
}
.menu-left {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 18px;
}
.kicker {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 5px;
  text-transform: uppercase;
  color: var(--amber);
}
.title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(46px, 7.4vw, 92px);
  line-height: 0.9;
  letter-spacing: 6px;
  text-shadow: 0 6px 30px rgba(0, 0, 0, 0.8);
}
.title span {
  color: transparent;
  -webkit-text-stroke: 2px var(--cyan);
  text-shadow: 0 0 34px rgba(53, 224, 216, 0.28);
}
.tagline {
  margin: 0;
  font-size: 17px;
  letter-spacing: 1px;
  color: var(--dim);
}
.controls-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
  padding: 14px 18px;
  border-left: 2px solid var(--amber);
  background: rgba(10, 13, 18, 0.6);
}
.control-line {
  font-family: var(--font-display);
  font-weight: 500;
  font-size: 14px;
  letter-spacing: 1.5px;
  color: var(--dim);
}
.control-line::before {
  content: '›';
  color: var(--amber);
  margin-right: 8px;
}

.menu-right {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.panel {
  background: linear-gradient(180deg, rgba(15, 19, 26, 0.92), rgba(9, 12, 17, 0.92));
  border: 1px solid var(--panel-border);
  clip-path: var(--clip);
  padding: 18px 20px;
}
.panel-title {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 4px;
  color: var(--dim);
  margin-bottom: 12px;
}
.panel-title::after {
  content: '';
  display: block;
  width: 34px;
  height: 2px;
  background: var(--amber);
  margin-top: 6px;
}

.profile-card {
  display: flex;
  align-items: center;
  gap: 14px;
}
.profile-card .face {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #10151c;
  border: 2px solid rgba(255, 176, 46, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  color: var(--amber);
  overflow: hidden;
  flex: none;
}
.profile-card .face img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.profile-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.profile-info b {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.profile-info span {
  font-size: 12px;
  color: var(--dim);
}

.board-panel {
  min-height: 220px;
}
.board {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.board-row {
  display: grid;
  grid-template-columns: 26px 10px minmax(0, 1fr) 48px 44px 52px;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  font-size: 13px;
  border-left: 2px solid transparent;
}
.board-row.me {
  background: rgba(53, 224, 216, 0.1);
  border-left-color: var(--cyan);
}
.board-rank {
  font-family: var(--font-mono);
  color: var(--dimmer);
  text-align: right;
}
.board-row:nth-child(1) .board-rank { color: var(--amber); }
.board-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  box-shadow: 0 0 6px rgba(255, 255, 255, 0.25);
}
.board-name {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.board-stat {
  font-family: var(--font-mono);
  font-size: 12px;
  text-align: right;
  color: var(--text);
}
.board-stat.dim {
  color: var(--dim);
}
.board-empty {
  color: var(--dim);
  font-size: 13px;
  font-style: italic;
  padding: 8px 0;
}

.btn {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 3px;
  text-transform: uppercase;
  padding: 14px 30px;
  border: none;
  cursor: pointer;
  clip-path: var(--clip);
  transition: transform 0.12s, box-shadow 0.2s, border-color 0.2s, background 0.2s;
}
.btn.primary {
  background: linear-gradient(180deg, var(--amber-hot), #ff9d1c);
  color: #17100a;
  box-shadow: 0 0 0 1px rgba(255, 200, 92, 0.45), 0 8px 34px rgba(255, 157, 28, 0.32);
}
.btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 0 1px rgba(255, 216, 140, 0.7), 0 12px 44px rgba(255, 157, 28, 0.45);
}
.btn.primary:active { transform: translateY(0) scale(0.98); }
.btn.ghost {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.16);
}
.btn.ghost:hover { border-color: var(--amber); color: var(--amber-hot); }
.btn.small {
  font-size: 13px;
  padding: 9px 16px;
  letter-spacing: 2px;
}

.go-wrap {
  display: grid;
  grid-template-columns: minmax(340px, 460px) minmax(300px, 380px);
  gap: 22px;
  width: min(920px, calc(100% - 48px));
  max-height: calc(100% - 40px);
}
#screen-gameover { background: rgba(4, 6, 10, 0.82); }
.go-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 26px;
}
.go-title {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 46px;
  letter-spacing: 10px;
  color: var(--red);
  text-shadow: 0 0 34px rgba(255, 77, 77, 0.35);
}
.go-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.go-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
}
.go-stat span {
  font-family: var(--font-mono);
  font-size: 26px;
  font-weight: 700;
}
.go-stat label {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--dim);
}
.save-status {
  min-height: 22px;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 1.5px;
}
.save-status.good { color: var(--cyan); }
.save-status.info { color: var(--dim); }
.save-status.warn { color: var(--amber); }
.save-status.saving { color: var(--dim); animation: hp-pulse 1s ease-in-out infinite; }
.go-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.go-board { overflow: auto; }

#screen-pause { background: rgba(4, 6, 10, 0.72); backdrop-filter: blur(3px); }
.pause-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(300px, calc(100% - 48px));
  padding: 28px;
}
.pause-panel h2 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 34px;
  letter-spacing: 10px;
  text-align: center;
}

#screen-draft { background: rgba(4, 6, 10, 0.78); backdrop-filter: blur(3px); }
.draft-wrap {
  text-align: center;
  width: min(860px, calc(100% - 40px));
}
.draft-wrap h2 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(28px, 4vw, 42px);
  letter-spacing: 8px;
  color: var(--amber);
  text-shadow: 0 0 40px rgba(255, 176, 46, 0.4);
}
.draft-sub {
  color: var(--dim);
  font-size: 14px;
  letter-spacing: 1px;
  margin: 8px 0 26px;
}
.draft-cards {
  display: flex;
  gap: 18px;
  justify-content: center;
  flex-wrap: wrap;
}
.draft-card {
  position: relative;
  width: 224px;
  padding: 44px 18px 18px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
  text-align: left;
  background: linear-gradient(180deg, rgba(18, 23, 31, 0.96), rgba(10, 13, 18, 0.96));
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
  cursor: pointer;
  font-family: var(--font-body);
  clip-path: var(--clip);
  transition: transform 0.16s cubic-bezier(0.2, 1.2, 0.4, 1), border-color 0.2s, box-shadow 0.2s;
}
.draft-card:hover {
  transform: translateY(-6px);
  border-color: var(--amber);
  box-shadow: 0 14px 44px rgba(0, 0, 0, 0.55), 0 0 24px rgba(255, 176, 46, 0.18);
}
.draft-card b {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 21px;
  letter-spacing: 2px;
}
.draft-desc {
  font-size: 13px;
  color: var(--dim);
  line-height: 1.4;
}
.draft-pips {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--dimmer);
  margin-top: 4px;
}
.draft-key {
  position: absolute;
  top: 12px;
  left: 14px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--dimmer);
  border: 1px solid rgba(255, 255, 255, 0.16);
}
.draft-card.rare {
  border-color: rgba(255, 176, 46, 0.55);
  box-shadow: 0 0 26px rgba(255, 176, 46, 0.14);
}
.draft-card.rare b { color: var(--amber-hot); }

#rotate {
  background: #05070c;
  flex-direction: column;
}
.rotate-inner { text-align: center; }
.rotate-phone {
  width: 54px;
  height: 92px;
  margin: 0 auto 26px;
  border: 3px solid var(--cyan);
  border-radius: 10px;
  animation: rotate-phone 2.2s ease-in-out infinite;
}
@keyframes rotate-phone {
  0%, 18% { transform: rotate(0deg); }
  55%, 100% { transform: rotate(90deg); }
}
.rotate-inner h2 {
  font-family: var(--font-display);
  font-weight: 700;
  letter-spacing: 6px;
  margin: 0 0 8px;
}
.rotate-inner p {
  color: var(--dim);
  margin: 0;
}

#touch {
  position: fixed;
  inset: 0;
  z-index: 25;
  touch-action: none;
}
.stick {
  position: fixed;
  display: none;
  width: 120px;
  height: 120px;
  margin: -60px 0 0 -60px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(10, 14, 20, 0.32);
  pointer-events: none;
}
.stick-nub {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(53, 224, 216, 0.24);
  border: 2px solid rgba(53, 224, 216, 0.8);
  transform: translate(-50%, -50%);
  box-shadow: 0 0 18px rgba(53, 224, 216, 0.3);
}
.dash-btn {
  position: fixed;
  right: calc(env(safe-area-inset-right, 0px) + 26px);
  bottom: calc(env(safe-area-inset-bottom, 0px) + 30px);
  width: 92px;
  height: 92px;
  border-radius: 50%;
  border: 2px solid rgba(255, 176, 46, 0.8);
  background: rgba(20, 13, 4, 0.55);
  color: var(--amber-hot);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 17px;
  letter-spacing: 2px;
  pointer-events: auto;
  touch-action: none;
  box-shadow: 0 0 24px rgba(255, 157, 28, 0.25);
}
.dash-btn:active {
  transform: scale(0.92);
  background: rgba(255, 157, 28, 0.3);
}

@media (max-width: 900px) {
  .menu-grid {
    grid-template-columns: 1fr;
    align-items: start;
    overflow: auto;
    padding: 16px 0;
    max-height: 100%;
  }
  .menu-right { width: 100%; }
  .go-wrap { grid-template-columns: 1fr; overflow: auto; }
  .hud-hp { min-width: 120px; }
  .hp-track { width: 34vw; }
  .hud-wave { font-size: 17px; letter-spacing: 2px; }
  .score-value { font-size: 20px; }
  .hud-timer { display: none; }
}

@media (max-height: 520px) {
  .title { font-size: clamp(34px, 9vh, 56px); }
  .controls-card { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .rotate-phone { animation: none; }
  .hp-fill.low { animation: none; }
  .banner.in .banner-main,
  .banner.in .banner-sub { animation-duration: 0.01s; }
}
