:root {
  --ink: #161616;
  --paper: #fff8ea;
  --sat: env(safe-area-inset-top);
  --sab: env(safe-area-inset-bottom);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #141414;
  font-family: "Jua", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  position: relative;
  height: 100%;
  max-width: 520px;
  margin: 0 auto;
  overflow: hidden;
  background: #8fd8ff;
  touch-action: none;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#sat-probe {
  position: absolute;
  top: 0;
  left: 0;
  width: 0;
  height: var(--sat);
  pointer-events: none;
}

button {
  font-family: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 4px solid var(--ink);
  border-radius: 16px;
  box-shadow: 0 4px 0 var(--ink);
  font-size: 18px;
  cursor: pointer;
  touch-action: manipulation;
}

button:active {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--ink);
}

button:disabled {
  opacity: 0.45;
  cursor: default;
  transform: none;
}

button:focus-visible {
  outline: 3px solid #1688d8;
  outline-offset: 2px;
}

.hidden { display: none !important; }

.screen {
  position: absolute;
  inset: 0;
  z-index: 7;
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
  padding: calc(12px + var(--sat)) 14px calc(16px + var(--sab));
}

.screen button,
.screen .panel,
.screen .card,
.screen .grid,
.screen a {
  pointer-events: auto;
}

.office-home {
  position: absolute;
  top: calc(8px + var(--sat));
  left: 10px;
  z-index: 2;
  padding: 6px 10px;
  font-size: 14px;
  text-decoration: none;
  color: #161616;
  background: #fff8ea;
  border: 3px solid #161616;
  border-radius: 12px;
  box-shadow: 0 3px 0 #161616;
}

.panel a.ghost-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 54px;
  font-size: 18px;
  text-decoration: none;
  color: #161616;
  background: #fff;
  border: 4px solid #161616;
  border-radius: 16px;
  box-shadow: 0 4px 0 #161616;
}

#screen-title {
  justify-content: flex-start;
  padding-top: calc(28px + var(--sat));
  gap: 6px;
}

.logo-wrap { text-align: center; line-height: 0.88; }

.logo-the {
  font-size: 28px;
  color: #fff;
  -webkit-text-stroke: 4px var(--ink);
  paint-order: stroke fill;
}

.logo-stick {
  font-size: clamp(52px, 14vw, 72px);
  color: #ffb703;
  -webkit-text-stroke: 7px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 6px 0 #e06a00;
}

.logo-fight {
  font-size: clamp(48px, 13vw, 68px);
  color: #ff5a3c;
  -webkit-text-stroke: 7px var(--ink);
  paint-order: stroke fill;
  text-shadow: 0 6px 0 #9d1d12;
}

.tag {
  margin: 4px 0 10px;
  font-size: 22px;
  color: #fff;
  -webkit-text-stroke: 4px var(--ink);
  paint-order: stroke fill;
}

.start-btn {
  min-width: 210px;
  height: 72px;
  font-size: 36px;
  background: #ffb703;
  border-radius: 22px;
  animation: pulse 1.1s ease-in-out infinite;
}

@keyframes pulse {
  50% { transform: scale(1.04); }
}

.start-btn:active { animation: none; }

.how, .credit {
  margin: 6px 0 0;
  color: #fff;
  -webkit-text-stroke: 3px var(--ink);
  paint-order: stroke fill;
  font-size: 16px;
  background: rgba(22, 18, 16, 0.38);
  border-radius: 999px;
  padding: 2px 12px;
}

.panel .tap {
  margin: 2px 0 0;
  color: #6b4a32;
  -webkit-text-stroke: 0;
  font-size: 14px;
}

.credit { margin-top: 8px; font-size: 15px; }

#screen-select {
  justify-content: space-between;
}

.select-head { text-align: center; }

.select-head h2,
.panel h2,
#win-title {
  margin: 0;
  font-size: 34px;
  color: #fff;
  -webkit-text-stroke: 5px var(--ink);
  paint-order: stroke fill;
}

.select-head p {
  margin: 6px auto 0;
  color: #fff;
  -webkit-text-stroke: 3px var(--ink);
  paint-order: stroke fill;
  font-size: 15px;
  background: rgba(22, 18, 16, 0.45);
  border-radius: 12px;
  padding: 4px 10px;
  max-width: 340px;
}

.select-bottom {
  width: min(480px, 100%);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  text-align: left;
  padding: 8px 10px 10px;
  min-height: 108px;
  background: #fff;
}

.card strong { font-size: 18px; }

.card span {
  font-size: 12px;
  line-height: 1.25;
  font-weight: 400;
}

.card.selected {
  background: #fff4b0;
  box-shadow: 0 4px 0 var(--ink), 0 0 0 3px #1688d8;
}

#btn-next, .panel button {
  width: 100%;
  height: 54px;
  font-size: 24px;
}

#btn-next { background: #ffb703; }

.panel {
  margin: auto;
  width: min(420px, 100%);
  background: var(--paper);
  border: 4px solid var(--ink);
  border-radius: 24px;
  box-shadow: 0 8px 0 var(--ink);
  padding: 18px 16px 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.panel h2 {
  color: var(--ink);
  -webkit-text-stroke: 0;
  text-shadow: none;
}

.panel p {
  margin: 0;
  white-space: pre-line;
  font-size: 17px;
  line-height: 1.35;
}

.kicker {
  font-size: 14px;
  letter-spacing: 1px;
  color: #c2410c;
}

.stars { font-size: 20px; letter-spacing: 3px; }

.panel .ghost { background: #fff; font-size: 18px; }

.champion {
  background: linear-gradient(#fff8ea, #d9f6ff);
}

#btn-pause {
  position: absolute;
  top: calc(8px + var(--sat));
  right: 8px;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  width: 78px;
  height: 44px;
  padding: 0 8px;
  font-size: 15px;
  color: #2a1c12;
  border: 3px solid #3a2616;
  border-radius: 14px;
  background: linear-gradient(180deg, #fffdf8 0%, #ffe7b0 48%, #e7b45a 100%);
  box-shadow:
    0 4px 0 #6a4318,
    0 8px 14px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.9);
}

.pause-bars {
  display: inline-block;
  width: 11px;
  height: 13px;
  background:
    linear-gradient(#2a1c12, #2a1c12) left center / 3.5px 100% no-repeat,
    linear-gradient(#2a1c12, #2a1c12) right center / 3.5px 100% no-repeat;
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.45));
}

#btn-pause:active {
  transform: translateY(3px) scale(0.95);
  box-shadow:
    0 1px 0 #6a4318,
    inset 0 3px 6px rgba(70, 40, 10, 0.28);
}

#controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  height: 116px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 8px calc(10px + var(--sab));
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(16, 10, 8, 0.18) 28%, rgba(12, 8, 6, 0.62) 100%);
}

#controls button {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  min-width: 0;
  height: 64px;
  padding: 0 2px;
  overflow: hidden;
  font-size: 15px;
  color: #2a1c12;
  border: 3px solid #2c1c12;
  border-radius: 18px;
  background: linear-gradient(180deg, #fffef9 0%, #f3ddb4 46%, #d7b072 100%);
  box-shadow:
    0 5px 0 #5c3b16,
    0 8px 12px rgba(0, 0, 0, 0.28),
    inset 0 2px 0 rgba(255, 255, 255, 0.85);
  transition: transform 0.06s ease, box-shadow 0.06s ease, filter 0.06s ease;
}

#controls button::after {
  content: "";
  position: absolute;
  left: 8px;
  right: 8px;
  top: 4px;
  height: 12px;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(255, 255, 255, 0));
  pointer-events: none;
}

#controls button:active {
  transform: translateY(4px) scale(0.95);
  box-shadow:
    0 1px 0 #5c3b16,
    inset 0 4px 8px rgba(40, 24, 8, 0.28);
  filter: brightness(1.08);
}

#btn-mine::before,
#btn-skill::before,
#btn-attack::before {
  font-size: 16px;
  line-height: 1;
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.2));
}

#btn-mine::before { content: "⛏"; }
#btn-skill::before { content: "✦"; }
#btn-attack::before { content: "⚔"; }

#controls button.primary {
  flex: 1.35;
  color: #fff;
  font-size: 18px;
  border-color: #6e1212;
  background: linear-gradient(180deg, #ff8a7a 0%, #ff3d3d 46%, #c41414 100%);
  box-shadow:
    0 5px 0 #6a1010,
    0 8px 14px rgba(120, 16, 16, 0.35),
    inset 0 2px 0 rgba(255, 255, 255, 0.45);
}

#controls button.primary:active {
  box-shadow:
    0 1px 0 #6a1010,
    inset 0 4px 8px rgba(80, 0, 0, 0.35);
}

#controls button.primary.hot {
  color: #062033;
  border-color: #0d4e78;
  background: linear-gradient(180deg, #d9f7ff 0%, #3ec8ff 42%, #1288d0 100%);
  box-shadow:
    0 5px 0 #0c4f86,
    0 0 16px rgba(80, 200, 255, 0.65),
    inset 0 2px 0 rgba(255, 255, 255, 0.7);
}

#controls button.mine {
  color: #fff;
  border-color: #5a3410;
  background: linear-gradient(180deg, #f0c27a 0%, #c4843a 48%, #8a4e16 100%);
  box-shadow:
    0 5px 0 #5a3010,
    0 8px 12px rgba(0, 0, 0, 0.28),
    inset 0 2px 0 rgba(255, 255, 255, 0.4);
}

#controls button.mine.ready {
  color: #2a1c12;
  border-color: #8a5a10;
  background: linear-gradient(180deg, #fff4c4 0%, #ffb703 48%, #e09000 100%);
  box-shadow:
    0 5px 0 #8a5208,
    0 0 14px rgba(255, 183, 3, 0.55),
    inset 0 2px 0 rgba(255, 255, 255, 0.7);
  animation: pulse 0.8s ease-in-out infinite;
}

#btn-skill.cooldown { filter: saturate(0.45) brightness(0.92); }

@media (max-height: 560px) {
  #controls { height: 86px; }
  #controls button { height: 52px; font-size: 14px; }
  .logo-stick { font-size: 44px; }
  .logo-fight { font-size: 40px; }
  .start-btn { height: 56px; font-size: 28px; }
  .card { min-height: 88px; }
}

@media (max-width: 360px) {
  #controls button { font-size: 13px; }
  .card span { font-size: 11px; }
}
