:root {
  --bg: #ece8df;
  --panel: #f5f1e8;
  --border: #111;
  --text: #111;
  --muted: #555;
  --red: #d61f1f;
  --green: #1ea34a;
  --blue: #2563eb;
  --card: #efefef;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: var(--bg);
  color: var(--text);
}

a {
  color: inherit;
  text-decoration: none;
}

.page-shell {
  padding: 12px;
}

/* Home */
.home-main {
  display: grid;
  grid-template-columns: minmax(700px, 1fr) 380px;
  gap: 12px;
  align-items: start;
}

.worlds-panel,
.side-box {
  background: var(--panel);
  border: 6px solid var(--border);
  padding: 14px;
}

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

.panel-header h1,
.side-box h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.custom-btn {
  border: 3px solid var(--border);
  background: #fff;
  padding: 10px 16px;
  font-weight: 800;
}

.custom-btn:hover {
  background: #f0f0f0;
}

.world-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(200px, 1fr));
  gap: 18px 22px;
}

.world-card,
.mini-world-card {
  display: block;
}

.world-card {
  background: #ddd;
  padding: 14px;
  border: 3px solid transparent;
}

.world-card:hover,
.mini-world-card:hover {
  border-color: #000;
}

.world-card .thumb-wrap {
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: #ccc;
}

.world-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.world-card-title {
  margin-top: 10px;
  font-size: 28px;
  font-weight: 900;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.home-side {
  display: grid;
  gap: 12px;
}

.side-list {
  display: grid;
  gap: 16px;
  margin-top: 14px;
}

.mini-world-card {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 16px;
  align-items: center;
  padding: 4px;
}

.mini-world-card .mini-thumb {
  width: 140px;
  height: 78px;
  object-fit: cover;
  display: block;
}

.mini-world-title {
  font-size: 28px;
  font-weight: 900;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Game */
.game-header {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 12px;
}

.back-link {
  border: 3px solid var(--border);
  background: #fff;
  padding: 9px 12px;
  font-weight: 800;
}

.header-world-title {
  font-size: 28px;
  font-weight: 900;
}

.header-world-subtitle {
  font-size: 14px;
  color: var(--muted);
  margin-top: 2px;
}

.header-round-block {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 420px;
}

.header-start-btn {
  width: auto !important;
  min-width: 150px;
  padding: 10px 16px;
  border: 3px solid var(--border);
  background: #fff;
  font-weight: 800;
  font-size: 15px;
}

.round-top-status {
  font-size: 14px;
  font-weight: 800;
  color: var(--text);
  line-height: 1.3;
}

.app {
  display: grid;
  grid-template-columns: minmax(640px, 1fr) 420px;
  gap: 16px;
  min-height: calc(100vh - 80px);
}

.left,
.right {
  background: var(--panel);
  border: 4px solid var(--border);
  padding: 12px;
}

.title {
  margin: 0 0 10px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.subline {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--muted);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.countdown {
  min-width: 280px;
  text-align: right;
  font-size: 28px;
  font-weight: 900;
  color: var(--red);
  line-height: 1.1;
}

.map-wrap {
  position: relative;
  width: 100%;
  height: 80vh;
  max-height: 80vh;
  background: #ddd;
  border: 4px solid var(--border);
  overflow: auto;
  user-select: none;
}

.map-wrap img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
  transform-origin: top left;
}

.overlay {
  position: absolute;
  top: 0;
  left: 0;
  cursor: crosshair;
  transform-origin: top left;
}

.zoom-row {
  display: grid;
  grid-template-columns: 120px 1fr 70px;
  gap: 10px;
  align-items: center;
  margin-top: 10px;
}

.zoom-value {
  font-weight: 800;
  text-align: right;
}

.controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
  align-items: end;
}

.control {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.control.full {
  grid-column: 1 / -1;
}

label {
  font-size: 13px;
  font-weight: 700;
}

input[type="number"],
input[type="file"],
input[type="range"],
button {
  width: 100%;
  padding: 10px 12px;
  border: 2px solid var(--border);
  font-size: 14px;
  background: #fff;
}

button {
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  background: #f0f0f0;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.legend {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  margin-top: 8px;
  font-size: 13px;
  font-weight: 700;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 999px;
  border: 2px solid #111;
  display: inline-block;
}

.red { background: var(--red); }
.green { background: var(--green); }
.blue { background: var(--blue); }

.photo-box {
  border: 4px solid var(--border);
  background: #ddd;
  aspect-ratio: 4 / 3;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-bottom: 12px;
}

.photo-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #ddd;
}

.placeholder {
  padding: 20px;
  text-align: center;
  color: var(--muted);
  font-weight: 700;
}

.stats {
  border: 4px solid var(--border);
  padding: 10px;
  background: #fff;
  min-height: 180px;
}

.stats h3 {
  margin: 0 0 10px;
  font-size: 18px;
  text-transform: uppercase;
}

.score-total,
.multiplier {
  font-size: 16px;
  font-weight: 800;
  margin-bottom: 8px;
}

.round-list {
  margin: 0;
  padding-left: 20px;
}

.round-list li {
  margin-bottom: 6px;
  font-size: 14px;
}

.hint {
  margin-top: 12px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--muted);
}

.status {
  margin-top: 12px;
  padding: 10px;
  border: 3px solid var(--border);
  background: #fff;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
  white-space: pre-line;
}

.image-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
}

.image-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
}

.image-modal-content {
  position: relative;
  z-index: 2;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px;
}

.image-modal-img {
  max-width: calc(100vw - 60px);
  max-height: calc(100vh - 60px);
  object-fit: contain;
  background: #111;
  border: 4px solid #fff;
}

.image-modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 52px;
  height: 52px;
  border: 3px solid #fff;
  background: #111;
  color: #fff;
  font-size: 30px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}

#locationImage {
  cursor: zoom-in;
}

@media (max-width: 1200px) {
  .home-main {
    grid-template-columns: 1fr;
  }

  .app {
    grid-template-columns: 1fr;
  }

  .header-round-block {
    min-width: 0;
    flex-direction: column;
    align-items: flex-start;
  }
}

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

  .mini-world-card {
    grid-template-columns: 120px 1fr;
  }

  .mini-world-card .mini-thumb {
    width: 120px;
    height: 68px;
  }
}

.mp-btn {
  margin-top: 12px;
  width: 100%;
  border: 3px solid var(--border);
  background: #fff;
  padding: 10px 12px;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
}

.mp-btn:hover {
  background: #f0f0f0;
}

.mp-btn:disabled {
  opacity: 0.7;
  cursor: wait;
}