:root {
  --paper: #e9ddc3;
  --paper-dark: #d7c6a2;
  --ink: #3d3228;
  --roof: #815844;
  --wall: #efe6d0;
  --line: #705644;
  --rain: #6e93a8;
  --leaf: #6c8763;
  --alert: #873d2f;
  --gold: #b58b47;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.45), transparent 38%),
    linear-gradient(180deg, #c1ccb7 0%, #a2b39d 100%);
  color: var(--ink);
  font-family: "Georgia", "Palatino Linotype", serif;
  touch-action: none;
  user-select: none;
}

body {
  display: flex;
}

.shell {
  flex: 1;
  min-height: 100%;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
}

.frame {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 24px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.08)),
    linear-gradient(180deg, #d9d0ba 0%, #c8bea7 100%);
  box-shadow:
    inset 0 0 0 2px rgba(95, 71, 50, 0.28),
    0 18px 40px rgba(60, 45, 25, 0.16);
}

#game {
  width: 100%;
  height: 100%;
  display: block;
}

.hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 18px;
}

.titleBlock {
  max-width: min(460px, 75vw);
  padding: 10px 14px 12px;
  background: rgba(244, 238, 223, 0.72);
  border: 1px solid rgba(112, 86, 68, 0.35);
  border-radius: 14px;
  backdrop-filter: blur(3px);
}

.titleBlock h1 {
  margin: 0 0 2px;
  font-size: clamp(1.35rem, 2.9vw, 2.2rem);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.titleBlock p {
  margin: 0;
  font-size: clamp(0.9rem, 1.8vw, 1rem);
  line-height: 1.3;
}

.statusRow {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  flex-wrap: wrap;
}

.controls {
  display: flex;
  gap: 10px;
  align-self: flex-start;
  pointer-events: auto;
}

.controlButton {
  appearance: none;
  border: 1px solid rgba(112, 86, 68, 0.5);
  background: rgba(244, 238, 223, 0.95);
  color: var(--ink);
  border-radius: 999px;
  padding: 10px 14px;
  font: inherit;
  font-size: 0.92rem;
  cursor: pointer;
  box-shadow: 0 6px 12px rgba(70, 54, 37, 0.08);
}

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

.paperTag,
.hint,
.message {
  padding: 9px 12px;
  background: rgba(244, 238, 223, 0.9);
  border: 1px solid rgba(112, 86, 68, 0.38);
  border-radius: 12px;
  box-shadow: 0 6px 12px rgba(70, 54, 37, 0.08);
}

.paperTag {
  font-size: 0.96rem;
}

.paperTag.wide {
  max-width: min(540px, 78vw);
}

.hint {
  align-self: flex-start;
  font-size: 0.92rem;
  max-width: min(360px, 80vw);
  transition: opacity 280ms ease;
}

.hint.gone {
  opacity: 0;
}

.message {
  align-self: center;
  margin-bottom: 8vh;
  max-width: min(560px, 88vw);
  text-align: center;
  font-size: clamp(1rem, 2.2vw, 1.2rem);
}

@media (max-width: 720px) {
  .hud {
    padding: 12px;
  }

  .titleBlock {
    max-width: 100%;
  }

  .statusRow {
    gap: 8px;
  }

  .controls {
    gap: 8px;
  }

  .paperTag,
  .hint,
  .message {
    font-size: 0.88rem;
    padding: 8px 10px;
  }

  .controlButton {
    font-size: 0.86rem;
    padding: 9px 12px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .hint {
    transition: none;
  }
}
