:root {
  color-scheme: light;
  --ink: #17212b;
  --muted: #61707d;
  --panel: #fffaf1;
  --line: #d8cbb5;
  --green: #5f8d56;
  --blue: #4078a8;
  --red: #b95a4b;
  --gold: #d49a37;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--ink);
  background: #c9dbd1;
}

button {
  font: inherit;
}

.shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 16px;
}

.game-card {
  width: min(1180px, 100%);
  background: #f7efe1;
  border: 1px solid #c9b996;
  border-radius: 8px;
  box-shadow: 0 20px 45px rgba(52, 68, 58, 0.2);
  overflow: hidden;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 14px 16px;
  background: #253c35;
  color: #fff9ed;
}

.eyebrow {
  margin: 0 0 2px;
  color: #f1c36a;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.1;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

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

.language-switcher {
  display: flex;
  gap: 4px;
}

.language-switcher a {
  padding: 7px 9px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 5px;
  color: #fff9ed;
  text-decoration: none;
  font-size: 12px;
}

.language-switcher a.active {
  background: #f1c36a;
  border-color: #f1c36a;
  color: #253c35;
  font-weight: 700;
}

.stats span {
  min-width: 78px;
  padding: 8px 10px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.1);
  text-align: center;
  font-weight: 700;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 230px;
  gap: 0;
}

.map-wrap {
  position: relative;
  min-width: 0;
  overflow: hidden;
  background: #b8d4ce;
}

canvas {
  width: 100%;
  aspect-ratio: 4 / 3;
  display: block;
  background: #b8d4ce;
  cursor: pointer;
  touch-action: none;
}

.map-controls {
  position: absolute;
  right: 12px;
  top: 12px;
  display: grid;
  gap: 6px;
}

.map-controls button {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid rgba(23, 33, 43, 0.35);
  border-radius: 6px;
  background: rgba(255, 253, 247, 0.94);
  color: var(--ink);
  box-shadow: 0 3px 10px rgba(23, 33, 43, 0.2);
  cursor: pointer;
  font-size: 22px;
  font-weight: 700;
}

.map-controls button:active {
  transform: translateY(1px);
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 14px;
  border-left: 1px solid var(--line);
  background: var(--panel);
}

.toolbox {
  display: grid;
  gap: 8px;
}

.tool,
.actions button {
  border: 1px solid #b8a889;
  border-radius: 6px;
  background: #fffdf7;
  color: var(--ink);
  cursor: pointer;
}

.tool {
  min-height: 54px;
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 8px;
  text-align: left;
}

.tool.active {
  border-color: #315c47;
  background: #e4f0df;
  box-shadow: inset 4px 0 0 #315c47;
}

.icon {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 6px;
  background: #263c35;
  color: #fff;
  font-weight: 800;
}

.tool strong {
  color: var(--muted);
  font-size: 12px;
}

.readout {
  display: grid;
  gap: 8px;
  padding-top: 4px;
}

.readout p {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin: 0;
  padding: 9px 0;
  border-bottom: 1px solid #e3d7be;
}

.readout span {
  color: var(--muted);
}

.readout strong {
  text-align: right;
}

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

.actions button {
  min-height: 42px;
  font-weight: 700;
}

.hint {
  min-height: 40px;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
  color: #3f4e3f;
  background: #fff8e9;
  font-size: 14px;
}

@media (max-width: 780px) {
  .shell {
    padding: 0;
  }

  .game-card {
    min-height: 100vh;
    border-radius: 0;
    border: 0;
  }

  .topbar {
    align-items: flex-start;
  }

  .topbar-right {
    align-items: flex-end;
    flex-direction: column;
    gap: 7px;
  }

  h1 {
    font-size: 20px;
  }

  .stats span {
    min-width: 64px;
    padding: 7px 8px;
    font-size: 13px;
  }

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

  .panel {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

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

  .tool {
    grid-template-columns: 1fr;
    justify-items: center;
    text-align: center;
  }

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