:root {
  --bg-dark: #141c17;
  --panel-bg: rgba(20, 29, 23, 0.94);
  --card-bg: rgba(31, 44, 35, 0.88);
  --border: rgba(154, 196, 152, 0.22);
  --text: #eef5ee;
  --muted: #9eb3a2;
  --accent: #e58e26;
  --accent-hover: #f3a13b;
  --green: #44bd32;
  --pine: #d48c46;
  --spruce: #2f7d4b;
  --birch: #a8d878;
  --danger: #e84118;
  --radius: 12px;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-dark);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

.hidden {
  display: none !important;
}

/* Yläpalkki */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 16px;
  background: rgba(16, 24, 19, 0.96);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.brand-icon {
  font-size: 26px;
  line-height: 1;
}

.brand h1 {
  font-size: 17px;
  letter-spacing: 0.8px;
  font-weight: 800;
  color: #f6e58d;
  line-height: 1.1;
}

.version-tag {
  font-size: 11px;
  color: var(--muted);
}

/* Hakupalkki */
.search-box {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  max-width: 560px;
}

.search-box input {
  flex: 1;
  height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  font-size: 14px;
  outline: none;
}

.search-box input:focus {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.12);
}

.search-results {
  position: absolute;
  top: 44px;
  left: 0;
  right: 0;
  background: #1b2620;
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
  overflow: hidden;
  z-index: 1400;
}

.search-result-item {
  padding: 10px 12px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.search-result-item:hover {
  background: rgba(229, 142, 38, 0.18);
}

/* Painikkeet */
.btn {
  height: 38px;
  padding: 0 14px;
  border: none;
  border-radius: 8px;
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
  transition: transform 0.1s ease, background 0.15s ease;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: var(--accent);
  color: #1a1204;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid var(--border);
}

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

.btn-dark {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.btn-dark:hover {
  background: #25362b;
}

.btn-icon {
  width: 38px;
  padding: 0;
  font-size: 16px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid var(--border);
}

.btn-cta {
  width: 100%;
  height: 48px;
  margin-top: 12px;
  font-size: 16px;
  background: linear-gradient(135deg, #e58e26, #d35400);
  color: #fff;
  box-shadow: 0 6px 20px rgba(229, 142, 38, 0.35);
}

.btn-cta:hover {
  filter: brightness(1.08);
}

/* Yläpalkin kassa */
.player-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.stat-pill {
  display: flex;
  flex-direction: column;
  padding: 4px 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border);
  line-height: 1.15;
}

.stat-cash {
  border-color: rgba(246, 229, 141, 0.45);
  background: rgba(246, 229, 141, 0.12);
}

.stat-label {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--muted);
  letter-spacing: 0.4px;
}

.stat-val {
  font-size: 15px;
  font-weight: 800;
  color: #f6e58d;
}

/* Näkymät */
.view {
  position: fixed;
  top: 60px;
  left: 0;
  right: 0;
  bottom: 0;
  display: none;
}

.view.active {
  display: block;
}

#map {
  width: 100%;
  height: 100%;
  background: #1b2820;
}

/* Kartan ohjepalkki & tasovalitsin */
.map-hint {
  position: absolute;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 800;
  padding: 10px 18px;
  border-radius: 999px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  font-size: 13px;
  box-shadow: var(--shadow);
  pointer-events: none;
  max-width: 92vw;
  text-align: center;
}

.layer-switcher {
  position: absolute;
  top: 14px;
  left: 54px;
  z-index: 800;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.layer-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.layer-btn.active {
  background: var(--accent);
  color: #1a1204;
}

.toggle-borders {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  padding: 0 8px;
  cursor: pointer;
  color: var(--text);
  border-left: 1px solid var(--border);
}

/* Analyysipaneeli */
.analysis-panel {
  position: absolute;
  top: 14px;
  right: 14px;
  bottom: 14px;
  width: 390px;
  max-width: calc(100vw - 28px);
  z-index: 950;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  overflow-y: auto;
  backdrop-filter: blur(10px);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 14px;
}

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(68, 189, 50, 0.2);
  color: #7bed9f;
  border: 1px solid rgba(123, 237, 159, 0.35);
  margin-bottom: 6px;
}

.badge.thinning {
  background: rgba(229, 142, 38, 0.22);
  color: #f6b93b;
  border-color: rgba(246, 185, 59, 0.4);
}

.badge.young, .badge.estimated {
  background: rgba(112, 161, 255, 0.18);
  color: #a4c8ff;
  border-color: rgba(164, 200, 255, 0.35);
}

.panel-header h2 {
  font-size: 20px;
  line-height: 1.2;
}

.ktunnus-sub {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.btn-close {
  border: none;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 15px;
}

.btn-close:hover {
  background: rgba(255, 255, 255, 0.18);
}

.loading-box {
  padding: 36px 14px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid rgba(255, 255, 255, 0.12);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.error-box {
  padding: 14px;
  border-radius: 10px;
  background: rgba(232, 65, 24, 0.18);
  border: 1px solid rgba(232, 65, 24, 0.45);
  color: #ffb8a8;
  font-size: 13px;
  line-height: 1.45;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.metric-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

.m-label {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 2px;
}

.metric-card strong {
  font-size: 17px;
  color: var(--text);
}

.species-section {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin-bottom: 14px;
}

.species-labels {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 7px;
}

.species-bar {
  display: flex;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.08);
}

.bar-seg.pine { background: var(--pine); }
.bar-seg.spruce { background: var(--spruce); }
.bar-seg.birch { background: var(--birch); }

.reco-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.reco-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.reco-icon {
  font-size: 20px;
  line-height: 1.2;
}

.reco-label {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 2px;
}

.reco-row p {
  font-size: 13px;
  line-height: 1.4;
}

.mhy-note {
  font-size: 12px;
  font-style: italic;
  color: #f6e58d;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}

.scene-meta {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  margin-top: 8px;
}

/* 3D-näkymä */
#canvas-wrap {
  width: 100%;
  height: 100%;
  cursor: pointer;
}

#floating-texts {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 900;
}

.float-euro {
  position: absolute;
  font-size: 22px;
  font-weight: 900;
  color: #f9ca24;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.85);
  transform: translate(-50%, -50%);
  animation: floatUp 1.3s ease-out forwards;
}

@keyframes floatUp {
  0% { opacity: 1; transform: translate(-50%, -40%) scale(0.85); }
  25% { opacity: 1; transform: translate(-50%, -85%) scale(1.15); }
  100% { opacity: 0; transform: translate(-50%, -175%) scale(1); }
}

.hud-left {
  position: absolute;
  top: 14px;
  left: 14px;
  z-index: 950;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 290px;
  max-width: calc(100vw - 28px);
}

.parcel-hud-card {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  box-shadow: var(--shadow);
}

.parcel-hud-card h3 {
  font-size: 16px;
}

.hud3d-sub {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 10px;
}

.prog-header, .prog-meta {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}

.prog-track {
  height: 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  margin: 6px 0;
  overflow: hidden;
}

.prog-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #44bd32, #f9ca24);
  transition: width 0.25s ease;
}

.earned-val {
  color: #f6e58d;
  font-weight: 800;
}

.hud3d-quip {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: #cfe4d3;
  line-height: 1.35;
}

.hud-bottom {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 950;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 18px;
  font-size: 12px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  box-shadow: var(--shadow);
  pointer-events: none;
}

.tree-tooltip {
  position: fixed;
  z-index: 1100;
  pointer-events: none;
  background: rgba(15, 23, 18, 0.94);
  border: 1px solid rgba(246, 229, 141, 0.45);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  box-shadow: var(--shadow);
  white-space: nowrap;
}

@media (max-width: 820px) {
  .brand .version-tag { display: none; }
  .search-box #btn-demo-parcel { display: none; }
  .hud-bottom { font-size: 11px; padding: 6px 12px; }
}
