/**
 * gorilla.css
 */

:root {
  --font-pixel: 'PixelMplus10 Regular', monospace;
  --color-bg: #222;
  --color-primary: #367594;
  --color-primary-dark: #3a6e98;
  --color-text: #eee;
  --color-title: #4f91a9;
  --color-subtitle: #115693;
  --color-panel: #79abc2;
  --color-hp-bg: #550000;
  --color-hp-fill: #39cf39;
  --color-danger: rgb(240, 68, 68);
  --color-shadow: rgba(0, 0, 0, 0.5);
  --color-overlay: rgba(0, 0, 40, 0.6);
  --color-log-bg: rgba(0, 0, 0, 0.8);
  --shadow-box: 0 0 20px var(--color-shadow);
  --shadow-text: 3px 3px 0 #000;
  --radius-sm: 3px;
  --radius-md: 4px;
  --radius-lg: 12px;
  --z-title: 9999;
  --z-header: 2000;
  --z-ui: 200;
  --z-overlay: 1500;
  --z-bubble: 1000;
}

@font-face {
  font-family: 'PixelMplus10 Regular';
  src: url('https://cdn.leafscape.be/PixelMplus/PixelMplus10-Regular_web.woff2') format('woff2');
}

html {
  overflow-x: hidden;
}

body {
  font-family: var(--font-pixel);
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  margin: 0;
  background-color: var(--color-bg);
}

.checkerboard {
  width: 100%;
  background-color: var(--color-primary);
  background-image:
    linear-gradient(45deg, var(--color-primary-dark) 25%, transparent 25%, transparent 75%, var(--color-primary-dark) 75%),
    linear-gradient(45deg, var(--color-primary-dark) 25%, transparent 25%, transparent 75%, var(--color-primary-dark) 75%);
  background-size: 40px 40px;
  background-position: 0 0, 20px 20px;
  text-align: center;
}

#title-screen {
  position: fixed;
  inset: 0;
  background-color: #000;
  color: var(--color-text);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: var(--z-title);
  font-family: var(--font-pixel);
}

.title-content {
  text-align: center;
}

h1.main-title {
  font-size: 3rem;
  margin-bottom: 20px;
  text-shadow: 4px 4px #555;
}

#start-button,
#start-button-with-bgm {
  background: none;
  border: none;
  font-size: 1.5rem;
  font-family: var(--font-pixel);
  cursor: pointer;
  animation: blink 0.8s infinite;
  display: none;
}

#start-button {
  color: var(--color-text);
  padding-right: 30px;
}

#start-button-with-bgm {
  color: var(--color-danger);
  margin-top: 2px;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

@keyframes fadeout {
  0%, 50% { opacity: 1; }
  100%    { opacity: 0; }
}

@keyframes fadein {
  0%, 50% { opacity: 0; }
  100%    { opacity: 1; }
}

@keyframes scroll-up {
  0%   { top: 100%; }
  100% { top: -4000%; }
}

@keyframes walk-anim {
  from { background-position: 0 0; }
  to   { background-position: -463px 0; }
}

@keyframes sweep-anim {
  from { background-position: 0 0; }
  to   { background-position: -463px 0; }
}

#game-stage {
  position: relative;
  width: 600px;
  height: 600px;
  background-image: url('/assets/bg_room_clean.png');
  background-size: cover;
  overflow: hidden;
  cursor: crosshair;
  box-shadow: var(--shadow-box);
  border-radius: var(--radius-md);
  transform-origin: center center;
  flex-shrink: 0;
}

.room_item {
  position: absolute;
  width: 600px;
  height: 600px;
  overflow: hidden;
  flex-shrink: 0;
}

#houseplant {
  position: absolute;
  bottom: -37px;
  left: -94px;
  width: 351px;
  height: 594px;
  background-image: url(/assets/houseplant.png);
  z-index: 91;
  transform: scale(0.2);
}

#game_cassettes {
  position: absolute;
  bottom: 31px;
  left: -111px;
  width: 542px;
  height: 491px;
  background-image: url(/assets/game_cassettes.png);
  z-index: 90;
  transform: scale(0.2);
}

#desk {
  position: absolute;
  bottom: 162px;
  left: 127px;
  width: 362px;
  height: 362px;
  background-image: url(/assets/desk.png);
  z-index: 92;
  transform: scale(0.5);
}

#desk.fadein {
  animation: fadein 0.8s forwards;
}

#desk.fadeout {
  animation: fadeout 0.6s forwards;
}

#desk2 {
  position: absolute;
  bottom: 158.9px;
  left: 127px;
  width: 363px;
  height: 365px;
  background-image: url(/assets/desk-2.png);
  z-index: 91;
  transform: scale(0.5);
}

#window {
  position: absolute;
  bottom: 96px;
  left: 273px;
  width: 387px;
  height: 530px;
  background-image: url(/assets/window_morning.png);
  z-index: 92;
  transform: scale(0.4);
}

#treasure_box {
  position: absolute;
  bottom: 39px;
  left: 294px;
  width: 404px;
  height: 423px;
  background-image: url(/assets/treasure_box.png);
  z-index: 92;
  transform: scale(0.25);
  filter: blur(1.5px);
}

#chair {
  position: absolute;
  width: 96px;
  height: 99px;
  bottom: 212px;
  left: 175px;
  background-image: url(/assets/chair.png);
  background-size: cover;
  z-index: 90;
  filter: blur(0.4px);
}

#gorilla {
  position: absolute;
  width: 91px;
  height: 100px;
  background-image: url('/assets/gorilla_sprite.png');
  background-position: 0 0;
  image-rendering: pixelated;
  transform-origin: center bottom;
  left: 268px;
  top: 300px;
  pointer-events: none;
  transition: left 1s linear, top 1s linear;
  z-index: 317;
}

#gorilla.is-walking {
  animation: walk-anim 0.4s steps(4) infinite;
}

#gorilla.is-sweeping {
  animation: sweep-anim 0.4s steps(3) infinite;
}

#gorilla.face-left {
  transform: scaleX(-1);
}

#gorilla.face-left .bubble {
  transform: scaleX(-1);
}

.is-sleeping {
  filter: brightness(0.7);
  transition: filter 1s;
}

#gorilla-sleeping {
  position: absolute;
  width: 130px;
  height: 100px;
  background-image: url(/assets/sleeping-gorilla.png);
  background-position: 0 0;
  background-size: cover;
  image-rendering: pixelated;
  transform-origin: center bottom;
  left: 280px;
  top: 350px;
  pointer-events: none;
  display: none;
  z-index: 102;
}

#gorilla-gaming {
  position: absolute;
  width: 253px;
  height: 279px;
  background-image: url(/assets/gaming-gorilla.png);
  background-position: 0 0;
  background-size: cover;
  image-rendering: pixelated;
  transform-origin: center bottom;
  left: 103px;
  top: 106px;
  pointer-events: none;
  display: none;
  z-index: 102;
  filter: blur(0.4px);
  transform: scale(0.4);
}

#gorilla-gardening {
  position: absolute;
  width: 508px;
  height: 479px;
  background-image: url(/assets/gardening-gorilla.png);
  background-position: 0 0;
  background-size: cover;
  image-rendering: pixelated;
  transform-origin: center bottom;
  left: -124px;
  bottom: 211px;
  pointer-events: none;
  display: none;
  z-index: 102;
  filter: blur(3px);
  transform: scale(0.23);
}

.bubble {
  position: absolute;
  bottom: 110%;
  left: 50%;
  transform: translateX(-50%);
  min-width: 80px;
  max-width: 300px;
  white-space: normal;
  text-align: center;
  background: #fff;
  border: 2px solid #333;
  padding: 8px 12px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.4;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.2);
  display: none;
  pointer-events: auto !important;
  cursor: pointer;
  z-index: var(--z-bubble);
}

.bubble::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 8px solid transparent;
  border-top-color: #fff;
}

.bubble a {
  display: block;
  color: inherit;
  text-decoration: none;
}

.end-roll-content {
  position: absolute;
  top: 100%;
  width: 100%;
  color: var(--color-text);
  z-index: 103;
}

.end-roll-content h2,
.end-roll-content p {
  padding-bottom: 300px;
}

.end-roll-content p {
  padding-bottom: 500px;
}

.header {
  position: absolute;
  top: 30px;
  left: 50%;
  transform: translateX(-50%);
  text-align: center;
  z-index: var(--z-header);
  pointer-events: none;
  text-shadow: #5bab94 1px 0 10px;
}

.maintitle {
  font-size: clamp(24px, 5vw, 40px);
  font-weight: bold;
  margin: 0;
  color: var(--color-title);
  text-shadow: var(--shadow-text);
}

.subtitle {
  font-size: clamp(12px, 3vw, 18px);
  margin: 5px 0 0;
  color: var(--color-subtitle);
  font-weight: bold;
}

#ui-container {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  z-index: var(--z-ui);
}

.pixel-btn {
  background-color: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  background-size: contain;
  background-repeat: no-repeat;
  image-rendering: pixelated;
  transition: transform 0.05s;
  width: 96px;
  height: 32px;
}

.pixel-btn:active {
  transform: translateY(2px);
}

#btn-post    { background-image: url('/assets/btn_post.png'); }
#btn-tweet   { background-image: url('/assets/btn_tweet.png'); }
#btn-paint   { background-image: url('/assets/btn_paint.png'); }
#btn-scripts { background-image: url('/assets/btn_scripts.png'); }
#btn-archive { background-image: url('/assets/btn_archive.png'); }

#btn-post:active    { background-image: url('/assets/btn_post_on.png'); }
#btn-tweet:active   { background-image: url('/assets/btn_tweet_on.png'); }
#btn-paint:active   { background-image: url('/assets/btn_paint_on.png'); }
#btn-scripts:active { background-image: url('/assets/btn_scripts_on.png'); }
#btn-archive:active { background-image: url('/assets/btn_archive_on.png'); }

#musicBtn {
  position: absolute;
  right: 12px;
  bottom: 1px;
  width: 20px;
  height: 20px;
  background-image: url(/assets/bgm_off.gif);
  background-size: cover;
  background-color: transparent;
  border: none;
  cursor: pointer;
  z-index: var(--z-ui);
}

#volSlider {
  position: absolute;
  right: 85px;
  bottom: 0;
  z-index: var(--z-ui);
}

#volValue {
  position: absolute;
  right: 40px;
  bottom: 2px;
  color: var(--color-subtitle);
}

#night-overlay {
  position: absolute;
  inset: 0;
  background-color: var(--color-overlay);
  mix-blend-mode: multiply;
  pointer-events: none;
  z-index: var(--z-overlay);
  display: none;
}

#goodnight {
  position: absolute;
  left: 77px;
  top: -127px;
  width: 737px;
  height: 611px;
  background-image: url(/assets/gameover.png);
  transform: scale(0.25);
  z-index: 103;
  display: none;
}

#intruder-sprite {
  position: absolute;
  width: 64px;
  height: auto;
  bottom: 150px;
  left: -100px;
  transition: left 0.8s ease-out;
  filter: blur(0.4px);
  display: none;
  z-index: 150;
}

.mirror {
  transform: scaleX(-1);
}

#ui-panel {
  position: relative;
  bottom: 0;
  left: 0;
  width: 600px;
  background-color: var(--color-panel);
  padding: 0 10px 0 40px;
  box-sizing: border-box;
  color: var(--color-panel);
  border-radius: var(--radius-sm);
  z-index: var(--z-ui);
}

.status-row {
  display: flex;
  align-items: center;
  height: 30px;
}

.status-label {
  margin-right: 10px;
  font-size: 20px;
  color: var(--color-text);
}

#hp-bar-outer {
  flex-grow: 1;
  height: 24px;
  background-color: var(--color-hp-bg);
  margin-right: 10px;
  position: relative;
}

#hp-bar-inner {
  width: 100%;
  height: 100%;
  background-color: var(--color-hp-fill);
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1), background-color 0.5s ease;
}

#hp-text {
  font-size: 18px;
  min-width: 80px;
  text-align: right;
  color: var(--color-text);
}

#message-log-container {
  width: 573px;
  height: 120px;
  background: var(--color-log-bg);
  border: 4px solid #fff;
  margin: 10px auto;
  padding: 10px;
  overflow-y: auto;
  scroll-behavior: smooth;
  position: relative;
  border-radius: var(--radius-sm);
  transform-origin: top center;
}

#message-log-container::-webkit-scrollbar {
  width: 3px;
}

#message-log-container::-webkit-scrollbar-track {
  background: transparent;
}

#message-log-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
}

#message-log-container::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.35);
}

#message-log-container {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

#message-log {
  color: #fff;
  font-size: 16px;
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  text-align: left;
}

.log-line {
  margin-bottom: 5px;
  word-wrap: break-word;
  line-height: 38px;
  font-size: 22pt;
}

#sound-modal-overlay {
  position: absolute;
  top: 100vh;
  left: 100vh;
  width: 600px;
  height: 400px;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 151;
}

#sound-modal {
  background: #000;
  border: 4px solid #fff;
  padding: 20px;
  text-align: center;
  font-family: var(--font-pixel);
  color: #fff;
}

#sound-modal p {
  font-size: 20px;
  margin-bottom: 20px;
}

.modal-buttons button {
  background: #000;
  border: 2px solid #fff;
  color: #fff;
  font-family: var(--font-pixel);
  padding: 10px 20px;
  margin: 0 10px;
  cursor: pointer;
  font-size: 16px;
}

.modal-buttons button:hover {
  background: #fff;
  color: #000;
}
