:root {
  --bg: #0b0d12;
  --panel: #12151c;
  --line: #222734;
  --text: #e7e9ee;
  --dim: #7d8496;
  --red: #ff4d5e;
  --green: #3ddc97;
  --gold: #ffc94d;
  --mono: ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

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

.hidden {
  display: none !important;
}

kbd {
  font-family: var(--mono);
  font-size: 11px;
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  color: var(--dim);
  margin: 0 1px;
}

/* ---------- HUD ---------- */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  font-family: var(--mono);
}

.hud-left {
  position: absolute;
  top: 16px;
  left: 18px;
}

.hud-dim {
  color: var(--dim);
  font-size: 12px;
}

.hud-big {
  font-size: 30px;
  font-weight: 700;
}

.hud-prox {
  margin-top: 4px;
  font-size: 13px;
  font-weight: 700;
  color: var(--gold);
  min-height: 18px;
}

.hud-center {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
}

.hud-price {
  font-size: 28px;
  font-weight: 700;
}

.hud-dd {
  font-size: 15px;
  color: var(--red);
  font-weight: 700;
}

.hud-right {
  position: absolute;
  top: 14px;
  right: 16px;
  text-align: right;
}

#minimap {
  width: 150px;
  height: 180px;
  background: rgba(18, 21, 28, 0.8);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.hud-stats {
  margin-top: 6px;
  font-size: 12px;
  color: var(--dim);
  display: flex;
  gap: 14px;
  justify-content: flex-end;
}

.hud-stats b {
  color: var(--text);
}

.hud-msg {
  position: absolute;
  top: 34%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  font-size: 22px;
  font-weight: 700;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8);
  white-space: pre-line;
}

.hud-keys {
  position: absolute;
  right: 16px;
  bottom: 14px;
  font-size: 12px;
  color: var(--dim);
  text-align: right;
  line-height: 1.9;
  background: rgba(18, 21, 28, 0.75);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 12px;
}

@media (pointer: coarse) {
  .hud-keys {
    display: none;
  }
}

/* ---------- Overlays ---------- */
.overlay {
  position: fixed;
  inset: 0;
  overflow-y: auto;
  background: rgba(11, 13, 18, 0.92);
  backdrop-filter: blur(4px);
}

.menu-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 48px 24px 40px;
}

h1 {
  margin: 0;
  font-family: var(--mono);
  font-size: 54px;
  letter-spacing: -1px;
}

h1 span {
  color: var(--red);
  margin: 0 10px;
}

.tag {
  color: var(--dim);
  margin: 10px 0 30px;
  font-size: 16px;
}

h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--dim);
  margin: 26px 0 12px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(440px, 1fr));
  gap: 18px;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px;
  cursor: pointer;
  transition:
    transform 0.12s,
    border-color 0.12s;
}

.card:hover {
  transform: translateY(-2px);
  border-color: var(--red);
}

.card-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.card-ticker {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 30px;
}

.card-dd {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 20px;
  color: var(--red);
}

.card canvas {
  width: 100%;
  height: 190px;
  display: block;
  margin: 16px 0;
}

.card-meta {
  font-size: 15px;
  color: var(--dim);
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.card-best {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--gold);
  margin-top: 6px;
  min-height: 14px;
}

.foot {
  margin-top: 32px;
  font-size: 12px;
  color: var(--dim);
}

.foot a {
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}

.foot a:hover {
  color: var(--gold);
  border-color: var(--gold);
}

/* ---------- Result ---------- */
#result {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 13, 18, 0.7);
}

.result-card {
  width: min(520px, 92vw);
  max-height: 96vh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 26px;
  text-align: center;
}

.res-title {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 700;
}

.res-sub {
  color: var(--dim);
  margin-top: 6px;
  font-size: 14px;
}

.res-score {
  font-family: var(--mono);
  font-size: 46px;
  font-weight: 700;
  margin: 14px 0 8px;
}

.res-rows {
  font-family: var(--mono);
  font-size: 13px;
  text-align: left;
  margin: 0 auto;
  max-width: 340px;
}

.res-rows div {
  display: flex;
  justify-content: space-between;
  padding: 4px 0;
  border-bottom: 1px dashed var(--line);
}

.res-rows span:first-child {
  color: var(--dim);
}

.res-best {
  font-family: var(--mono);
  color: var(--gold);
  font-size: 13px;
  margin-top: 10px;
  min-height: 16px;
}

.res-share {
  margin: 14px 0;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  text-align: left;
  white-space: pre-wrap;
  user-select: text;
  -webkit-user-select: text;
}

.res-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

.res-buttons button,
.res-buttons a {
  font: 600 14px -apple-system, BlinkMacSystemFont, sans-serif;
  padding: 10px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}

.res-buttons .primary {
  background: var(--red);
  border-color: var(--red);
  color: #fff;
}

.res-buttons .primary kbd {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
}

#mute {
  position: fixed;
  left: 16px;
  bottom: 14px;
  z-index: 5;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(18, 21, 28, 0.8);
  font-size: 18px;
  cursor: pointer;
}

/* ---------- Phones (kept last so it wins over the rules above) ---------- */
@media (max-width: 600px) {
  .menu-inner {
    padding: 32px 16px 28px;
  }
  h1 {
    font-size: 40px;
  }
  h1 span {
    margin: 0 6px;
  }
  .tag {
    font-size: 15px;
  }
  .grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .card {
    padding: 16px;
  }
  .card-ticker {
    font-size: 24px;
  }
  .card-dd {
    font-size: 15px;
  }
  .card canvas {
    height: 140px;
    margin: 10px 0;
  }
  .card-meta {
    font-size: 13px;
  }
  /* HUD: price under the coin count, smaller minimap */
  .hud-left {
    top: 12px;
    left: 14px;
  }
  .hud-big {
    font-size: 24px;
  }
  .hud-center {
    top: 78px;
    left: 14px;
    transform: none;
    text-align: left;
  }
  .hud-price {
    font-size: 16px;
  }
  .hud-dd {
    font-size: 12px;
  }
  .hud-right {
    top: 12px;
    right: 12px;
  }
  #minimap {
    width: 84px;
    height: 101px;
  }
  .hud-stats {
    font-size: 11px;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
  }
  .hud-msg {
    width: 88vw;
    font-size: 17px;
  }
  .result-card {
    padding: 20px 16px;
  }
  .res-score {
    font-size: 36px;
  }
}

/* No keyboard on touch devices: hide key badges */
@media (pointer: coarse) {
  .res-buttons kbd {
    display: none;
  }
}
