:root {
  --bg: #0d1116;
  --bg-deep: #0a0e13;
  --panel: #141a22;
  --text: #f2f4f7;
  --muted: #a3afbf;
  --accent: #f77f2f;
  --accent-2: #1fbf9e;
  --border: rgba(255, 255, 255, 0.08);
  --shadow: 0 18px 38px rgba(0, 0, 0, 0.45);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  height: 100vh;
  height: 100dvh;
  font-family: "Space Grotesk", "Segoe UI", Tahoma, sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(247, 127, 47, 0.16) 0%, transparent 65%),
    radial-gradient(900px 500px at 90% -5%, rgba(31, 191, 158, 0.12) 0%, transparent 65%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-deep) 100%);
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
}

body.is-modal {
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.08), transparent 55%),
    radial-gradient(circle at 80% 10%, rgba(255, 255, 255, 0.06), transparent 60%),
    repeating-linear-gradient(
      140deg,
      rgba(255, 255, 255, 0.05) 0,
      rgba(255, 255, 255, 0.05) 2px,
      transparent 2px,
      transparent 12px
    );
  pointer-events: none;
  z-index: -1;
}

body::after {
  content: "";
  position: fixed;
  width: 520px;
  height: 520px;
  right: -180px;
  bottom: -220px;
  background: radial-gradient(circle, rgba(31, 191, 158, 0.18), transparent 70%);
  pointer-events: none;
  z-index: -1;
}

.topbar {
  padding: clamp(10px, 2vw, 16px) clamp(12px, 2.6vw, 18px) clamp(8px, 1.8vw, 12px);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px 16px;
  align-items: center;
  background: rgba(13, 17, 22, 0.85);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(14px);
  animation: rise-in 0.5s ease both;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 6px rgba(247, 127, 47, 0.2);
}

.brand-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.brand-subtitle {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.2em;
  color: var(--muted);
}

.controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

#btnRules {
  border-color: rgba(247, 127, 47, 0.9);
  color: #f77f2f;
}

#btnRules:hover {
  border-color: rgba(247, 127, 47, 1);
  box-shadow: 0 14px 26px rgba(247, 127, 47, 0.45);
}

.btn {
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.35);
}

.btn-blocked {
  color: #ff4d4f;
  border-color: rgba(255, 77, 79, 0.6);
  text-decoration: line-through;
  text-decoration-color: rgba(255, 77, 79, 0.85);
  text-decoration-thickness: 2px;
}

.btn-blocked:disabled {
  opacity: 0.85;
}

.btn-new {
  order: 10;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: transparent;
}

.btn-secondary {
  border-color: rgba(247, 127, 47, 0.45);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.06);
}

.btn:hover {
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 14px 26px rgba(0, 0, 0, 0.45);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.btn:focus-visible {
  outline: 2px solid rgba(31, 159, 138, 0.5);
  outline-offset: 2px;
}

.scoreboard {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}

.score {
  background: rgba(20, 26, 34, 0.92);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  display: grid;
  gap: 6px;
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.35);
}

.label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--muted);
}

.value {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.value.is-hardcore {
  color: #ff4d4f;
}

.value.pop {
  animation: pop 0.38s ease;
}

.status {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  font-size: 14px;
  color: var(--muted);
}

.result {
  color: var(--accent-2);
  font-weight: 700;
}

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: 1.25fr 0.75fr;
  gap: 0;
  padding: 0;
  min-height: 0;
}

.panel {
  background: transparent;
  border: 0;
  border-radius: 0;
  overflow: hidden;
  position: relative;
  min-height: 0;
  box-shadow: none;
  animation: panel-in 0.6s ease both;
}

.panel:nth-child(2) {
  animation-delay: 0.12s;
}

.panel--pano::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.12), transparent 60%);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

body.is-loading .panel--pano::after {
  opacity: 0.25;
}

.pano,
.map {
  width: 100%;
  height: 100%;
  min-height: 0;
}

.pano {
  position: relative;
  background: #0b0f14;
}

.pano-hint {
  position: absolute;
  top: 22px;
  right: 16px;
  z-index: 3;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 12px;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.45);
}

.map {
  position: relative;
  z-index: 0;
}

.map-shell {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 0;
}

.map-loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  background: linear-gradient(180deg, rgba(13, 17, 22, 0.9), rgba(13, 17, 22, 0.75)),
    linear-gradient(120deg, rgba(247, 127, 47, 0.2), transparent 55%);
  border-radius: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(6px);
  padding: 12px;
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease;
}

.map-loading--hidden {
  opacity: 0;
  transform: scale(0.95);
  pointer-events: none;
  visibility: hidden;
}

.map-loading span {
  font-weight: 600;
  letter-spacing: 0.2em;
}

.map-loading-bar {
  width: min(220px, 70vw);
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.map-loading-bar span {
  display: block;
  width: 40%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(247, 127, 47, 0.45), rgba(31, 191, 158, 0.95));
  animation: panoLoading 1.6s ease-in-out infinite;
  transform-origin: left center;
  transform: translateX(-50%) scaleX(0.8);
  opacity: 0.95;
}

.pano-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  background: #0b0f14;
}

.hint-box {
  position: absolute;
  left: 12px;
  top: 12px;
  max-width: min(360px, 85%);
  padding: 8px 12px;
  border-radius: 12px;
  background: rgba(20, 26, 34, 0.88);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 12px;
  line-height: 1.4;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: none;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.hint-box span {
  display: inline-flex;
  gap: 4px;
}

.hint-penalty {
  margin-left: auto;
  color: #ff5e5e;
  font-weight: 600;
  font-size: 0.82em;
}

.hint-box.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.pano-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -60%) scale(0.95);
  opacity: 0;
  pointer-events: none;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 16px 18px;
  border-radius: 18px;
  background: rgba(13, 17, 22, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 24px 40px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.08);
  font-size: clamp(16px, 2vw, 20px);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.pano-loading-bar {
  width: min(220px, 70vw);
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.pano-loading-bar span {
  display: block;
  width: 25%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(247, 127, 47, 0.4), var(--accent));
  animation: panoLoading 1.4s ease-in-out infinite;
  transform-origin: left center;
  transform: translateX(-50%) scaleX(0.6);
  opacity: 0.9;
}

body.is-loading .pano-loading {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.hint {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  padding: 10px 12px;
  font-size: 12px;
  color: var(--muted);
  background: rgba(20, 26, 34, 0.9);
  border: 1px solid var(--border);
  border-radius: 12px;
  backdrop-filter: blur(6px);
}

.map-tools {
  position: absolute;
  top: 12px;
  left: auto;
  right: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 1001;
  pointer-events: auto;
}

.map-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.map-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.map-actions .btn {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  min-width: auto;
  box-shadow: none;
}

.map-search {
  display: flex;
  gap: 6px;
  align-items: center;
  flex: 1;
  width: min(280px, 70vw);
  padding: 6px;
  border-radius: 16px;
  background: rgba(20, 26, 34, 0.92);
  border: 1px solid var(--border);
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.4);
  pointer-events: auto;
  position: relative;
  z-index: 1002;
}

.map-search.is-blocked {
  border-color: rgba(255, 77, 79, 0.7);
  background: rgba(80, 20, 20, 0.35);
  box-shadow: none;
}

.map-search.is-blocked::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  top: 50%;
  height: 2px;
  background: rgba(255, 77, 79, 0.85);
  transform: translateY(-50%);
  pointer-events: none;
}

.map-search.is-blocked input {
  text-decoration: line-through;
  text-decoration-color: rgba(255, 77, 79, 0.85);
  text-decoration-thickness: 2px;
}

.map-search.is-blocked .btn {
  border-color: rgba(255, 77, 79, 0.5);
  color: #ff4d4f;
}

.map-search input {
  flex: 1;
  border: 0;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 0 12px;
  height: 34px;
  border-radius: 12px;
  font-family: "Space Grotesk", "Segoe UI", Tahoma, sans-serif;
  min-width: 0;
  font-size: 13px;
}

.map-search input::placeholder {
  color: rgba(163, 175, 191, 0.6);
}

.map-search input:focus {
  outline: 2px solid rgba(77, 163, 255, 0.5);
  outline-offset: 2px;
}

.map-search .btn {
  padding: 0 12px;
  height: 34px;
  border-radius: 12px;
  box-shadow: none;
  min-width: 62px;
  font-size: 12px;
  line-height: 1;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
}

.map-suggestions {
  width: min(280px, 70vw);
  display: none;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  border-radius: 12px;
  background: rgba(20, 26, 34, 0.95);
  border: 1px solid var(--border);
  box-shadow: 0 12px 22px rgba(0, 0, 0, 0.4);
  pointer-events: auto;
}

.map-suggestions.is-visible {
  display: flex;
}

.map-suggestion {
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.map-suggestion:hover,
.map-suggestion:focus-visible {
  outline: none;
  background: rgba(255, 255, 255, 0.08);
}

.map-suggestion-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.map-suggestion-type {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 999px;
  flex-shrink: 0;
}

.map-suggestion-type--capital {
  color: #4da3ff;
  border-color: rgba(77, 163, 255, 0.5);
}

.map-suggestion-type--country {
  color: #f0c94c;
  border-color: rgba(240, 201, 76, 0.5);
}

.map-search-status {
  font-size: 12px;
  color: var(--muted);
  min-height: 14px;
  padding-left: 6px;
  text-align: right;
}

.level-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(10px, 2vw, 24px);
  background: rgba(10, 14, 19, 0.92);
  backdrop-filter: blur(10px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  z-index: 5;
}

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

.level-card {
  width: min(1200px, 96vw);
  max-height: min(520px, 92vh);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: clamp(12px, 2vw, 22px) clamp(14px, 2.4vw, 24px);
  display: grid;
  gap: clamp(10px, 1.6vw, 16px);
  box-shadow: var(--shadow);
}

.rules-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(12px, 2vw, 20px);
  background: rgba(10, 14, 19, 0.88);
  backdrop-filter: blur(12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 6;
}

.rules-modal.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.rules-card {
  width: min(520px, 92vw);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: var(--shadow);
}

.rules-header h2 {
  margin: 0;
  font-size: clamp(20px, 2.2vw, 24px);
}

.rules-header p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.rules-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 14px;
  line-height: 1.5;
}

.rules-body ul {
  margin: 0;
  padding-left: 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.rules-body li {
  list-style: disc;
}

.rules-actions {
  display: flex;
  justify-content: flex-end;
}

.rules-actions .btn {
  box-shadow: none;
}

.level-header h2 {
  margin: 0 0 6px;
  font-size: clamp(18px, 2.2vw, 22px);
}

.level-header p {
  margin: 0;
  color: var(--muted);
  font-size: clamp(12px, 1.6vw, 14px);
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(clamp(150px, 18vw, 220px), 1fr));
  gap: clamp(8px, 1.4vw, 12px);
}

.level-btn {
  --level-accent: rgba(255, 255, 255, 0.28);
  text-align: left;
  padding: clamp(10px, 1.4vw, 14px) clamp(12px, 1.6vw, 16px);
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(20, 26, 34, 0.95);
  display: grid;
  gap: clamp(6px, 1vw, 8px);
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  box-shadow: 0 14px 24px rgba(0, 0, 0, 0.45);
  position: relative;
  overflow: hidden;
}

.level-btn::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  height: 4px;
  width: 100%;
  background: linear-gradient(90deg, var(--level-accent), transparent 70%);
  opacity: 0.75;
}

.level-btn::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(140deg, rgba(255, 255, 255, 0.08), transparent 55%);
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
}

.level-btn--hardcore {
  --level-accent: #ff4d4f;
  border-color: rgba(255, 77, 79, 0.65);
  background: rgba(120, 20, 20, 0.35);
}

.level-btn--hardcore .level-name {
  color: #ff4d4f;
}

.level-btn--hardcore .level-note {
  display: block;
  margin-top: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: rgba(255, 77, 79, 0.15);
  color: #ff6f61;
}

.level-btn--capital {
  --level-accent: #4da3ff;
  border-color: rgba(77, 163, 255, 0.7);
  background: rgba(16, 40, 88, 0.35);
}

.level-btn--capital .level-name {
  color: #4da3ff;
}

.level-btn--easy {
  --level-accent: #3dca7a;
  border-color: rgba(61, 202, 122, 0.7);
  background: rgba(24, 66, 40, 0.35);
}

.level-btn--easy .level-name {
  color: #3dca7a;
}

.level-btn--medium {
  --level-accent: #f0c94c;
  border-color: rgba(240, 201, 76, 0.7);
  background: rgba(80, 64, 18, 0.35);
}

.level-btn--medium .level-name {
  color: #f0c94c;
}

.level-btn--hard {
  --level-accent: #d8741a;
  border-color: rgba(216, 116, 26, 0.7);
  background: rgba(70, 30, 8, 0.5);
}

.level-btn--hard .level-name {
  color: #d8741a;
}

.level-btn:hover {
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 16px 26px rgba(0, 0, 0, 0.55);
}

.level-btn:hover::after {
  opacity: 1;
}

.level-btn.level-btn--capital:hover {
  border-color: rgba(77, 163, 255, 0.95);
  box-shadow: 0 16px 26px rgba(77, 163, 255, 0.18);
}

.level-btn.level-btn--easy:hover {
  border-color: rgba(61, 202, 122, 0.95);
  box-shadow: 0 16px 26px rgba(61, 202, 122, 0.18);
}

.level-btn.level-btn--medium:hover {
  border-color: rgba(240, 201, 76, 0.95);
  box-shadow: 0 16px 26px rgba(240, 201, 76, 0.18);
}

.level-btn.level-btn--hard:hover {
  border-color: rgba(216, 116, 26, 0.95);
  box-shadow: 0 16px 26px rgba(216, 116, 26, 0.18);
}

.level-btn.level-btn--hardcore:hover {
  border-color: rgba(255, 77, 79, 0.9);
  box-shadow: 0 16px 26px rgba(255, 77, 79, 0.18);
}

.level-btn:active {
  transform: translateY(1px);
}

.level-name {
  font-size: clamp(13px, 1.8vw, 16px);
  font-weight: 700;
  color: var(--text);
}

.level-desc {
  font-size: clamp(11px, 1.4vw, 13px);
  color: var(--muted);
  line-height: 1.4;
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pop {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.08);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes panoLoading {
  0% {
    transform: translateX(-50%) scaleX(0.6);
    opacity: 0.9;
  }
  50% {
    transform: translateX(75%) scaleX(1);
    opacity: 1;
  }
  100% {
    transform: translateX(-50%) scaleX(0.6);
    opacity: 0.9;
  }
}

@media (max-width: 980px) {
  .topbar {
    grid-template-columns: 1fr;
    justify-items: flex-start;
  }

  .controls {
    justify-content: flex-start;
  }

  .scoreboard {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: repeat(2, minmax(0, 1fr));
  }

  .level-card {
    width: min(960px, 96vw);
  }
}

@media (max-width: 640px) {
  .scoreboard {
    grid-template-columns: 1fr;
  }

}
.level-note {
  font-weight: 600;
}
