﻿@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');

@font-face {
  font-family: "GalmuriMono9";
  src: url("./GalmuriMono9.ttf") format("truetype");
  font-display: swap;
}

:root {
  --bg: #151a2a;
  --panel: #1f2a44;
  --frame: #e0d7b8;
  --grass: #3f6f3a;
  --path: #b79a6d;
  --water: #356f8f;
  --wall: #5d4c41;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: block;
  background-color: #000000;
  background-image: none;
  image-rendering: pixelated;
  color: var(--frame);
  font-family: 'Press Start 2P', monospace;
}

.app {
  text-align: center;
  padding: 16px;
  max-width: 920px;
  margin: 0 auto;
}

.top-bar {
  width: min(92vw, 760px);
  margin: 0 auto 10px;
  display: flex;
  justify-content: flex-end;
}

.top-toon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  margin: 0 0 16px;
}

.toon-img {
  width: min(92vw, 760px);
  height: auto;
  image-rendering: pixelated;
}

h1 {
  font-size: 16px;
  margin: 0 0 12px;
  font-family: "GalmuriMono9", monospace;
  font-weight: normal;
  line-height: 1.6;
  text-align: center;
}

.title-row {
  width: min(92vw, 760px);
  margin: 0 auto 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.title-row h1 {
  margin: 0;
  text-align: center;
}

.bgm-toggle {
  border: 2px solid #111;
  background: #d7d7d7;
  color: #111;
  font-family: "GalmuriMono9", monospace;
  font-size: 12px;
  padding: 6px 10px;
  cursor: pointer;
}

.bgm-toggle[aria-pressed="true"] {
  background: #a8d08d;
}

.screen-gap {
  height: 176px;
}

#game {
  border: 4px solid var(--frame);
  image-rendering: pixelated;
  width: min(92vw, 760px);
  height: auto;
  background: #000;
}

.game-shell {
  position: relative;
  display: inline-block;
  line-height: 0;
}

.pixel-transition {
  position: absolute;
  inset: 0;
  z-index: 18;
  opacity: 0;
  background-color: #000;
  background-image:
    linear-gradient(90deg, rgba(20, 20, 20, 0.35) 50%, rgba(0, 0, 0, 0.8) 50%),
    linear-gradient(rgba(20, 20, 20, 0.35) 50%, rgba(0, 0, 0, 0.8) 50%);
  background-size: 8px 8px;
  image-rendering: pixelated;
}

.pixel-transition.play {
  animation: pixel-blackout 900ms steps(12, end) forwards;
}

@keyframes pixel-blackout {
  0% {
    opacity: 0;
    background-size: 6px 6px;
  }
  100% {
    opacity: 1;
    background-size: 26px 26px;
  }
}

.ending-menu {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(86%, 380px);
  background: #f1f1f1;
  color: #111;
  border: 3px solid #111;
  box-shadow: inset 0 0 0 2px #f1f1f1, 0 0 0 2px #111;
  padding: 14px 12px;
  z-index: 22;
  text-align: center;
  font-family: "GalmuriMono9", monospace;
}

.ending-title {
  margin: 0 0 10px;
  font-size: 15px;
  line-height: 1.3;
}

.ending-link {
  display: inline-block;
  min-width: 140px;
  padding: 8px 12px;
  border: 2px solid #111;
  background: #d9d9d9;
  color: #111;
  text-decoration: none;
  font-size: 14px;
}

.ending-link:hover {
  background: #c7c7c7;
}

.ending-links {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.help {
  margin-top: 10px;
  font-size: 12px;
}

.controls-bar {
  margin-top: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  touch-action: none;
  user-select: none;
}

.control-btn {
  width: 56px;
  height: 56px;
  border: 0;
  padding: 0;
  background-color: transparent;
  background-image: url("./assets/buttons.png");
  background-repeat: no-repeat;
  background-size: 300% 200%;
  image-rendering: pixelated;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
}

.control-btn:active {
  transform: translateY(1px) scale(0.98);
}

.control-btn.up {
  background-position: 0% 0%;
}

.control-btn.down {
  background-position: 50% 0%;
}

.control-btn.action {
  background-position: 100% 0%;
}

.control-btn.left {
  background-position: 0% 100%;
}

.control-btn.right {
  background-position: 50% 100%;
}

@media (max-width: 520px) {
  .top-toon {
    gap: 10px;
  }

  .toon-img {
    width: min(94vw, 420px);
  }

  .title-row {
    width: min(94vw, 420px);
  }

  .top-bar {
    width: min(94vw, 420px);
    margin-bottom: 8px;
  }

  .bgm-toggle {
    font-size: 11px;
    padding: 5px 8px;
  }

  .control-btn {
    width: 46px;
    height: 46px;
  }

  .dialog {
    left: 10px;
    right: 10px;
    bottom: 8px;
    padding: 6px 8px;
    font-size: 11px;
    line-height: 1.35;
    max-height: 30%;
    overflow-y: auto;
  }

  .dialog .help {
    display: none;
  }
}

.dialog {
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 14px;
  background: #f1f1f1;
  color: #111;
  border: 3px solid #111;
  box-shadow: inset 0 0 0 2px #f1f1f1, 0 0 0 2px #111;
  padding: 10px 12px;
  font-size: 16px;
  line-height: 1.6;
  text-align: left;
  z-index: 10;
  font-family: "GalmuriMono9", monospace;
}

.dialog .help {
  margin-top: 8px;
  margin-bottom: 0;
  font-size: 12px;
  font-family: "GalmuriMono9", monospace;
}

.dialog p,
#dialogText {
  margin: 0;
}

.hidden {
  display: none;
}

.game-footer {
  margin-top: 40px;
  width: min(92vw, 760px);
  margin-left: auto;
  margin-right: auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: "GalmuriMono9", monospace;
  font-size: 12px;
  color: #bfbfbf;
}

.game-footer a {
  color: #bfbfbf;
  text-decoration: none;
}

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