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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #1a6894;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  -webkit-tap-highlight-color: transparent;
}

.screen {
  position: fixed;
  inset: 0;
  display: none;
}
.screen.active {
  display: block;
}

/* ── メイン画面 ── */
#beach-canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  touch-action: none;
}

#ui-bar {
  position: fixed;
  bottom: 16px;
  right: 12px;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  z-index: 100;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

#btn-zukan {
  width: 48px;
  height: 48px;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
  z-index: 100;
}
#btn-zukan canvas {
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#chest-btn {
  position: relative;
  width: 48px;
  height: 48px;
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
}
#chest-btn canvas {
  width: 48px;
  height: 48px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
#chest-count {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  line-height: 18px;
  text-align: center;
  background: #e85050;
  color: #fff;
  font-size: 10px;
  font-weight: bold;
  border-radius: 9px;
  padding: 0 4px;
  display: none;
}
#chest-count.show {
  display: block;
}

/* 回収アニメーション用の飛ぶドット */
.fly-item {
  position: fixed;
  pointer-events: none;
  z-index: 200;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  transition: all 0.4s cubic-bezier(0.2, 0.8, 0.3, 1);
}

/* ── 宝物部屋 & 図鑑 共通 ── */
#screen-treasure,
#screen-zukan {
  background: #1a1a28;
  overflow: hidden;
}

#treasure-canvas,
#zukan-canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.btn-back {
  position: fixed;
  bottom: 16px;
  right: 12px;
  padding: 8px 16px;
  border: 2px solid #e8c870;
  border-radius: 4px;
  background: rgba(30,30,40,0.85);
  color: #e8c870;
  font-size: 13px;
  font-weight: bold;
  cursor: pointer;
  z-index: 100;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
}

/* ── 手紙画面 ── */
#screen-letter {
  background: rgba(0,0,0,0.6);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 32px;
}
#screen-letter.active {
  display: flex;
}

.letter-paper {
  width: 100%;
  max-width: 320px;
  padding: 28px 24px 20px;
  background: #f5edd0;
  border: 3px solid #c0a060;
  border-radius: 4px;
  box-shadow: 0 4px 0 rgba(0,0,0,0.3);
}

#letter-text {
  font-size: 14px;
  line-height: 2;
  color: #504030;
  white-space: pre-wrap;
  min-height: 80px;
}

.letter-hint {
  text-align: center;
  margin-top: 16px;
  font-size: 11px;
  color: #a09070;
}
