/* Spillstil — mobile first, store touch-targets. */
* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #1f2a1f;
  background: #cfe7b8;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

body.game {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

.game__top {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  background: #2c5a2c;
  color: #fff;
  flex: 0 0 auto;
}

.game__back, .game__icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  background: rgba(255,255,255,0.12);
  border: none;
  border-radius: 10px;
  color: #fff;
  font-size: 1.4rem;
  text-decoration: none;
  cursor: pointer;
}

.game__title {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  line-height: 1.15;
  min-width: 0;
}

.game__title strong {
  font-size: 1.05rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.game__counter {
  font-size: 0.8rem;
  opacity: 0.85;
}

.game__comment {
  background: #fff8d8;
  border-bottom: 2px solid #ead78b;
  padding: 0.55rem 0.85rem;
  font-size: 0.95rem;
  color: #3d3a1f;
  flex: 0 0 auto;
}
.game__comment strong { color: #6a541b; }

.game__stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  background:
    linear-gradient(180deg, #b9dff2 0%, #d8efb8 60%, #a3c878 100%);
  overflow: hidden;
}

#canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.game__toolbar {
  flex: 0 0 auto;
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding: 0.6rem 0.75rem;
  background: #efe6cf;
  border-top: 2px solid #d4c79b;
  scrollbar-width: none;
}
.game__toolbar::-webkit-scrollbar { display: none; }

.tool {
  flex: 0 0 auto;
  min-width: 64px;
  min-height: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 14px;
  background: #fff;
  border: 2px solid transparent;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  cursor: pointer;
  font-size: 1.6rem;
  padding: 0.3rem 0.5rem;
  position: relative;
}

.tool[disabled] { opacity: 0.4; cursor: not-allowed; }
.tool.is-active { border-color: #3a7a3a; background: #eaf6da; }

.tool__count {
  font-size: 0.75rem;
  font-weight: 700;
  color: #2c5a2c;
}

.tool__label {
  font-size: 0.7rem;
  color: #3d4a3d;
}

.game__controls {
  flex: 0 0 auto;
  display: flex;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem 0.9rem;
  background: #efe6cf;
}

.btn {
  flex: 1 1 0;
  min-height: 52px;
  border: none;
  border-radius: 14px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0.6rem 0.8rem;
}

.btn--primary {
  background: #3a7a3a;
  color: #fff;
  box-shadow: 0 4px 0 #265226;
}
.btn--primary:active { transform: translateY(2px); box-shadow: 0 2px 0 #265226; }

.btn--ghost {
  background: #fff;
  color: #2c5a2c;
  border: 2px solid #c7b988;
}

.game__overlay {
  position: absolute;
  inset: 0;
  background: rgba(20, 30, 20, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 10;
}

.game__overlay[hidden] { display: none; }

.modal {
  background: #fff;
  border-radius: 18px;
  padding: 1.4rem 1.2rem;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  text-align: center;
}

.modal h2 {
  margin: 0 0 0.5rem;
  color: #2c5a2c;
}

.modal p {
  margin: 0 0 1rem;
  color: #3d4a3d;
}

.modal__buttons {
  display: flex;
  gap: 0.5rem;
}

.modal--levels { max-width: 420px; }

.levels-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin: 0.5rem 0 1rem;
  text-align: left;
}

.level-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.7rem 0.8rem;
  background: #f4ecd6;
  border: 2px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  font: inherit;
  width: 100%;
  text-align: left;
  min-height: 56px;
}
.level-row:hover  { border-color: #6aa66a; }
.level-row:active { transform: scale(0.99); }
.level-row.is-current { border-color: #3a7a3a; background: #e6f1cc; }

.level-row__num {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: #2c5a2c; color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700;
  flex: 0 0 auto;
}
.level-row__name { flex: 1 1 auto; color: #2c5a2c; font-weight: 600; }
.level-row__star { font-size: 1.2rem; color: #d6a420; }

/* Landscape: pakk toolbar og kontroller på siden hvis det er plass. */
@media (orientation: landscape) and (max-height: 500px) {
  .game__top { padding: 0.3rem 0.6rem; }
  .game__top strong { font-size: 0.95rem; }
  .game__comment { padding: 0.3rem 0.7rem; font-size: 0.85rem; }
  .btn { min-height: 44px; }
  .tool { min-width: 56px; min-height: 56px; font-size: 1.4rem; }
}
