* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0a0e17;
  font-family: 'Segoe UI', system-ui, sans-serif;
  color: #fff;
}

#gameCanvas {
  display: block;
  width: 100vw;
  height: 100vh;
  cursor: crosshair;
}

.hud {
  position: fixed;
  top: 16px;
  left: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: none;
  z-index: 5;
}

.hud-top {
  display: flex;
  gap: 12px;
}

.hud-pill {
  background: rgba(10, 14, 23, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.02em;
  backdrop-filter: blur(4px);
}

.hud-hint {
  background: rgba(10, 14, 23, 0.55);
  border-radius: 999px;
  padding: 4px 14px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.75);
}

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 40%, rgba(30, 41, 59, 0.85), rgba(5, 8, 14, 0.95));
  z-index: 10;
  transition: opacity 0.25s ease;
  /* Full-screen dim layer only — let clicks pass through to the top-left
     buttons underneath (Shop/Levels/Training/Maker); the panel itself
     re-enables pointer events for its own content. */
  pointer-events: none;
}

.overlay.hidden {
  display: none;
}

.overlay-panel {
  background: rgba(15, 20, 32, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  padding: 36px 44px;
  max-width: 420px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
}

.overlay-panel h1 {
  margin: 0 0 12px;
  font-size: 28px;
  background: linear-gradient(90deg, #ffd166, #ef476f, #06d6a0);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.overlay-panel p {
  color: rgba(255, 255, 255, 0.8);
  line-height: 1.5;
  margin: 0 0 18px;
}

.controls-list {
  list-style: none;
  padding: 0;
  margin: 0 0 22px;
  text-align: left;
  display: inline-block;
  color: rgba(255, 255, 255, 0.85);
  font-size: 14px;
  line-height: 1.9;
}

.play-button {
  background: linear-gradient(135deg, #06d6a0, #1b9aaa);
  border: none;
  color: #06131a;
  font-weight: 700;
  font-size: 16px;
  padding: 12px 28px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 8px 24px rgba(6, 214, 160, 0.35);
}

.play-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(6, 214, 160, 0.45);
}

.win-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.play-button.secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  box-shadow: none;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.play-button.secondary:hover {
  background: rgba(255, 255, 255, 0.16);
  box-shadow: none;
}

.coin-reward {
  color: #ffd166;
  font-weight: 700;
  font-size: 18px;
  margin: -8px 0 18px;
}

.top-left-buttons {
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 6;
  display: flex;
  gap: 8px;
}

.shop-button {
  background: rgba(10, 14, 23, 0.72);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(4px);
  transition: transform 0.15s ease, background 0.15s ease;
}

.shop-button:hover {
  background: rgba(20, 26, 40, 0.85);
  transform: translateY(-1px);
}

.shop-panel {
  max-width: 520px;
  width: 90%;
}

.level-panel {
  max-width: 480px;
  width: 90%;
}

.level-items {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}

.level-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 12px 16px;
  cursor: pointer;
  text-align: left;
  color: #fff;
  transition: transform 0.15s ease, background 0.15s ease;
}

.level-card:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.level-card-info {
  flex: 1;
}

.level-name {
  display: block;
  font-weight: 700;
  font-size: 16px;
}

.level-name.easy { color: #06d6a0; }
.level-name.medium { color: #ffd166; }
.level-name.hard { color: #ff8c42; }
.level-name.master { color: #ef476f; }
.level-name.combo {
  background: linear-gradient(90deg, #ff3d68, #a742ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.level-blurb {
  display: block;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.65);
  margin-top: 2px;
}

.level-reward {
  font-weight: 700;
  color: #ffd166;
  font-size: 14px;
  white-space: nowrap;
}

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

.shop-header h2 {
  margin: 0;
  font-size: 22px;
  background: linear-gradient(90deg, #ffd166, #ef476f, #06d6a0);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.shop-close {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
}

.shop-close:hover {
  background: rgba(255, 255, 255, 0.16);
}

.shop-intro {
  color: rgba(255, 255, 255, 0.7);
  font-size: 13px;
  margin: 0 0 14px;
}

.shop-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
}

.shop-tab {
  flex: 1;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.7);
  font-weight: 600;
  font-size: 12px;
  padding: 8px 0;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.shop-tab:hover {
  background: rgba(255, 255, 255, 0.1);
}

.shop-tab.active {
  background: linear-gradient(135deg, #06d6a0, #1b9aaa);
  color: #06131a;
  border-color: transparent;
}

.shop-items {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  max-height: 60vh;
  overflow-y: auto;
}

.shop-item {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  padding: 14px 10px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.shop-item.equipped {
  border-color: #06d6a0;
  box-shadow: 0 0 0 1px rgba(6, 214, 160, 0.4);
}

.shop-item-swatch {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
}

.shop-item-swatch-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  font-size: 20px;
}

.shop-item-name {
  font-size: 13px;
  font-weight: 600;
}

.shop-item-price {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
}

.shop-item-action {
  border: none;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
}

.shop-item-action.buy {
  background: linear-gradient(135deg, #06d6a0, #1b9aaa);
  color: #06131a;
}

.shop-item-action.buy:disabled {
  background: rgba(255, 255, 255, 0.1);
  color: rgba(255, 255, 255, 0.4);
  cursor: not-allowed;
}

.shop-item-action.equip {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.shop-item-action.equipped {
  background: rgba(6, 214, 160, 0.2);
  color: #06d6a0;
  cursor: default;
}

.back-to-editor {
  position: fixed;
  top: 16px;
  right: 16px;
  left: auto;
  z-index: 6;
}

.back-to-editor.hidden {
  display: none;
}

.editor-toolbar {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  z-index: 6;
  background: rgba(10, 14, 23, 0.88);
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(6px);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

.editor-toolbar.hidden {
  display: none;
}

.editor-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.editor-type-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.editor-type-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.editor-type-btn.active {
  background: linear-gradient(135deg, #06d6a0, #1b9aaa);
  color: #06131a;
  border-color: transparent;
}

.editor-size-row {
  align-items: center;
}

.editor-size-row label {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.75);
}

.editor-action-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.editor-action-btn:hover {
  background: rgba(255, 255, 255, 0.14);
}

.editor-action-btn.active {
  background: rgba(239, 71, 111, 0.35);
  border-color: rgba(239, 71, 111, 0.6);
}

.editor-action-btn.primary {
  background: linear-gradient(135deg, #06d6a0, #1b9aaa);
  color: #06131a;
  border-color: transparent;
}

.editor-hint {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
  text-align: center;
}

.account-panel {
  max-width: 380px;
  width: 90%;
}

.account-existing-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.account-existing-list:empty {
  display: none;
}

.account-chip {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  font-size: 13px;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
}

.account-chip:hover {
  background: rgba(255, 255, 255, 0.14);
}

.account-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 18px;
  text-align: left;
}

.account-form h3 {
  margin: 0 0 2px;
  font-size: 14px;
  color: rgba(255, 255, 255, 0.75);
}

.account-form input {
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  padding: 9px 12px;
  color: #fff;
  font-size: 14px;
  font-family: inherit;
}

.account-form input:focus {
  outline: none;
  border-color: #06d6a0;
}

.account-error {
  color: #ef476f;
  font-size: 12px;
  margin: 0;
  min-height: 14px;
}

.account-welcome {
  color: rgba(255, 255, 255, 0.85);
  font-size: 15px;
  margin: 4px 0 18px;
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 55vh;
  overflow-y: auto;
}

.leaderboard-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 10px 14px;
}

.leaderboard-row.current-user {
  border-color: #06d6a0;
  box-shadow: 0 0 0 1px rgba(6, 214, 160, 0.4);
}

.leaderboard-rank {
  font-weight: 700;
  font-size: 15px;
  width: 28px;
  text-align: center;
  color: rgba(255, 255, 255, 0.7);
}

.leaderboard-name {
  flex: 1;
  font-weight: 600;
  color: #fff;
  text-align: left;
}

.leaderboard-coins {
  font-weight: 700;
  color: #ffd166;
  white-space: nowrap;
}
