:root {
  --blue: #1565c0;
  --blue-dark: #0d47a1;
  --sky: #eef6ff;
  --paper: #ffffff;
  --ink: #17324d;
  --muted: #617487;
  --line: #cddff0;
  --grass: #6fbf73;
  --shadow: 0 10px 30px rgba(14, 48, 84, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", "Yu Gothic", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 0%, rgba(124, 183, 111, 0.24), transparent 30%),
    linear-gradient(180deg, #eaf7ff 0%, #f6fbff 55%, #eef4f8 100%);
}

body {
  padding: 14px 12px 50px;
}

button {
  font-family: inherit;
  touch-action: manipulation;
}

.app-shell {
  width: min(1040px, 100%);
  margin: 0 auto;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 12px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.hero h1 {
  margin: 0 0 5px;
  font-size: clamp(1.3rem, 3vw, 2rem);
  letter-spacing: 0.02em;
}

.hero p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 0.95rem;
}

.help-btn,
.restart-btn,
.tranq-btn,
.pad-btn {
  border: none;
  border-radius: 999px;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
  box-shadow: 0 3px 10px rgba(21, 101, 192, 0.22);
}

.help-btn {
  flex: 0 0 auto;
  padding: 8px 14px;
  font-size: 0.9rem;
}

.help-btn:hover,
.restart-btn:hover,
.tranq-btn:hover,
.pad-btn:hover,
.ad-close-btn:hover {
  background: var(--blue-dark);
}

.game-card {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.hud {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1px;
  background: var(--line);
  border-bottom: 1px solid var(--line);
}

.hud-item {
  min-width: 0;
  padding: 8px 6px;
  text-align: center;
  background: #f9fcff;
}

.hud-item span {
  display: block;
  font-size: 0.68rem;
  color: var(--muted);
  line-height: 1.1;
}

.hud-item strong {
  display: block;
  margin-top: 2px;
  font-size: clamp(0.88rem, 2.3vw, 1.12rem);
  line-height: 1.1;
}

.canvas-wrap {
  position: relative;
  width: 100%;
  background: #b7d990;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  image-rendering: auto;
}

.screen-message {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(86%, 520px);
  padding: 16px 18px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.75);
  background: rgba(7, 32, 53, 0.74);
  color: #fff;
  text-align: center;
  backdrop-filter: blur(4px);
  pointer-events: none;
}

.screen-message strong {
  display: block;
  font-size: clamp(1.05rem, 3vw, 1.45rem);
  margin-bottom: 7px;
}

.screen-message span {
  display: block;
  font-size: 0.88rem;
  line-height: 1.45;
}

.screen-message.hidden {
  display: none;
}

.control-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 10px 10px 12px;
  border-top: 1px solid var(--line);
  background: #f6fbff;
}

.pad {
  display: grid;
  grid-template-columns: 42px 42px 42px;
  grid-template-rows: 34px 34px;
  gap: 5px;
  align-items: center;
  justify-content: center;
}

.pad-btn {
  width: 42px;
  height: 34px;
  padding: 0;
  font-size: 0.88rem;
}

.pad-btn.up {
  grid-column: 2;
  grid-row: 1;
}

.pad-btn.left {
  grid-column: 1;
  grid-row: 2;
}

.pad-btn.down {
  grid-column: 2;
  grid-row: 2;
}

.pad-btn.right {
  grid-column: 3;
  grid-row: 2;
}

.tranq-btn {
  min-width: 76px;
  min-height: 52px;
  padding: 10px 16px;
  border-radius: 16px;
  font-size: 1rem;
}

.restart-btn {
  padding: 10px 14px;
  font-size: 0.9rem;
  background: #4c789e;
}

.notice-card {
  margin-top: 12px;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 5px 16px rgba(14, 48, 84, 0.08);
}

.notice-card h2 {
  margin: 0 0 8px;
  font-size: 1.05rem;
}

.notice-card p {
  margin: 7px 0 0;
  line-height: 1.65;
  color: #34495e;
  font-size: 0.92rem;
}

.ad-panel {
  width: min(880px, 100%);
  margin: 12px auto 0;
  padding: 0;
  border: 1px solid #d7e6f8;
  border-radius: 10px;
  background: #ffffff;
  overflow: hidden;
  box-shadow: 0 5px 18px rgba(14, 48, 84, 0.10);
}

.ad-panel[hidden] {
  display: none !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  height: 0 !important;
  overflow: hidden !important;
}

.ad-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 28px;
  padding: 5px 8px;
  background: #f4f8ff;
  border-bottom: 1px solid #d7e6f8;
}

.ad-label,
.ad-wait {
  font-size: 0.72rem;
  color: #4f6f91;
  line-height: 1.2;
}

.ad-wait {
  margin-left: auto;
}

.ad-close-btn {
  margin: 0 !important;
  padding: 3px 8px !important;
  min-height: 0;
  height: auto;
  line-height: 1.2;
  border: none;
  border-radius: 999px;
  background: var(--blue);
  color: #ffffff;
  font-size: 0.72rem !important;
  font-weight: 700;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.ad-body {
  min-height: 90px;
  padding: 8px;
  background: #ffffff;
}

.app-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  min-height: 30px;
  border-top: 1px solid #cfd8e3;
  background: #eef3f8;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.app-footer p {
  margin: 0;
  padding: 4px 10px;
  font-size: 0.78rem;
  line-height: 1.2;
  text-align: center;
  color: #1d4ed8;
}

.app-footer a {
  color: #1d4ed8;
  text-decoration: none;
}

.app-footer a:hover {
  text-decoration: underline;
}

@media (max-width: 720px) {
  body {
    padding: 8px 7px 48px;
  }

  .hero {
    padding: 12px;
    align-items: flex-start;
  }

  .hero p {
    font-size: 0.83rem;
  }

  .hud {
    grid-template-columns: repeat(5, 1fr);
  }

  .hud-item {
    padding: 7px 2px;
  }

  .control-strip {
    gap: 8px;
    padding: 8px 6px 10px;
  }

  .pad {
    grid-template-columns: 36px 36px 36px;
    grid-template-rows: 31px 31px;
    gap: 4px;
  }

  .pad-btn {
    width: 36px;
    height: 31px;
  }

  .tranq-btn {
    min-width: 66px;
    min-height: 48px;
    padding: 8px 12px;
  }

  .restart-btn {
    padding: 8px 10px;
  }

  .screen-message {
    padding: 12px 12px;
  }
}
