@font-face {
  font-family: "Minecraft Rus";
  src: url("./assets/fonts/minecraft.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --bg-top: #9fd7ff;
  --bg-bottom: #f9df92;
  --panel: rgba(13, 26, 39, 0.66);
  --panel-border: rgba(255, 255, 255, 0.18);
  --text-main: #f8fbff;
  --text-soft: rgba(248, 251, 255, 0.74);
  --accent: #ff8d44;
  --accent-2: #ffd668;
  --shadow: rgba(7, 15, 24, 0.24);
  --font-ui: "Minecraft Rus", "Trebuchet MS", "Segoe UI", sans-serif;
}

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

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  touch-action: none;
  font-family: var(--font-ui);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.55), transparent 26%),
    linear-gradient(180deg, var(--bg-top) 0%, #8aceff 42%, var(--bg-bottom) 100%);
}

button {
  font: inherit;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  border-radius: 999px;
  pointer-events: none;
  filter: blur(10px);
}

body::before {
  width: 34vmax;
  height: 34vmax;
  right: -8vmax;
  top: -12vmax;
  background: rgba(255, 255, 255, 0.22);
}

body::after {
  width: 42vmax;
  height: 20vmax;
  left: -9vmax;
  bottom: -8vmax;
  background: rgba(246, 164, 80, 0.28);
}

.shell,
#game-root,
canvas {
  width: 100%;
  height: 100%;
}

.shell {
  position: relative;
}

#game-root {
  position: relative;
}

canvas {
  display: block;
}

.hud {
  position: absolute;
  top: max(14px, env(safe-area-inset-top));
  left: max(14px, env(safe-area-inset-left));
  right: max(14px, env(safe-area-inset-right));
  z-index: 5;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.hud-panel {
  padding: 14px 16px;
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  background: var(--panel);
  backdrop-filter: blur(18px);
  box-shadow: 0 20px 40px var(--shadow);
}

.hud-brand {
  width: min(42ch, calc(100% - 28px));
}

.hud-stats {
  min-width: min(36ch, 48vw);
  max-width: min(38ch, calc(100% - 28px));
}

.hud-toolbar {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-bottom: 10px;
}

.panic-toggle,
.music-toggle {
  min-width: 112px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(13, 26, 39, 0.62);
  color: var(--text-main);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
  box-shadow: 0 10px 22px rgba(4, 11, 18, 0.18);
}

.panic-toggle {
  min-width: 134px;
  background:
    linear-gradient(180deg, rgba(255, 213, 180, 0.95), rgba(255, 133, 92, 0.98));
  color: #341913;
}

.music-toggle[data-state="on"] {
  background: rgba(255, 195, 80, 0.92);
  color: #18202a;
}

.badge {
  margin-bottom: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--accent-2);
}

.title {
  font-size: clamp(22px, 4vw, 34px);
  font-weight: 800;
  line-height: 0.95;
  color: var(--text-main);
}

.hint {
  margin-top: 8px;
  font-size: clamp(12px, 1.8vw, 15px);
  color: var(--text-soft);
}

.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.stat-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--accent-2);
}

.stat-value {
  font-size: 16px;
  font-weight: 800;
  color: var(--text-main);
}

.level-name {
  margin-top: 6px;
  margin-bottom: 10px;
  font-size: clamp(18px, 2vw, 22px);
  font-weight: 800;
  color: var(--text-main);
}

.hearts {
  display: flex;
  gap: 6px;
  margin: 12px 0 10px;
  min-height: 28px;
}

.heart {
  width: 34px;
  height: 24px;
  object-fit: contain;
  image-rendering: pixelated;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.18));
}

.heart.is-empty {
  opacity: 0.26;
  filter: grayscale(1);
}

.goal-text {
  font-size: 14px;
  line-height: 1.35;
  color: var(--text-soft);
}

.banner {
  position: absolute;
  left: 50%;
  top: max(18px, env(safe-area-inset-top));
  z-index: 7;
  transform: translateX(-50%);
  padding: 12px 18px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(13, 26, 39, 0.82);
  box-shadow: 0 18px 28px rgba(0, 0, 0, 0.18);
  color: var(--text-main);
  font-size: 14px;
  font-weight: 700;
  backdrop-filter: blur(16px);
}

.banner[data-tone="success"] {
  background: rgba(37, 98, 51, 0.86);
}

.banner[data-tone="warning"] {
  background: rgba(130, 89, 25, 0.88);
}

.banner[data-tone="danger"] {
  background: rgba(128, 42, 31, 0.88);
}

.touch-controls {
  position: absolute;
  inset: auto max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom))
    max(14px, env(safe-area-inset-left));
  z-index: 5;
  display: flex;
  justify-content: space-between;
  align-items: end;
  pointer-events: none;
}

.touch-pad {
  display: flex;
  gap: 12px;
}

.touch-actions {
  display: flex;
  gap: 12px;
}

.touch-btn {
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 20px;
  background: rgba(13, 26, 39, 0.74);
  color: var(--text-main);
  box-shadow: 0 16px 30px rgba(4, 11, 18, 0.3);
  backdrop-filter: blur(14px);
  pointer-events: auto;
  user-select: none;
}

.touch-move {
  width: min(16vw, 84px);
  height: min(16vw, 84px);
  font-size: clamp(28px, 5vw, 40px);
}

.touch-jump,
.touch-attack {
  min-width: min(22vw, 124px);
  height: min(14vw, 72px);
  padding: 0 20px;
  font-size: clamp(20px, 3.2vw, 28px);
  font-weight: 800;
}

.touch-jump {
  color: #18202a;
  background:
    linear-gradient(180deg, rgba(255, 243, 204, 0.95), rgba(255, 195, 80, 0.98));
}

.touch-attack {
  color: #fff7f1;
  background:
    linear-gradient(180deg, rgba(255, 173, 141, 0.98), rgba(231, 94, 70, 0.96));
}

.touch-btn:active,
.touch-btn.is-active {
  transform: translateY(2px) scale(0.98);
}

.rotate-device,
.loading-screen {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(4, 10, 17, 0.6);
  backdrop-filter: blur(18px);
}

.rotate-device[hidden],
.loading-screen[hidden],
.screen-message[hidden],
.gift-screen[hidden] {
  display: none;
}

.rotate-card,
.loading-card {
  width: min(420px, 100%);
  padding: 24px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(13, 26, 39, 0.8);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.22);
  text-align: center;
}

.screen-message {
  position: absolute;
  inset: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(4, 10, 17, 0.66);
  backdrop-filter: blur(18px);
}

.screen-card {
  width: min(460px, 100%);
  padding: 28px;
  border-radius: 26px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(13, 26, 39, 0.84);
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.22);
  text-align: center;
}

.rotate-title,
.loading-title {
  margin-bottom: 8px;
  font-size: clamp(24px, 4vw, 34px);
  font-weight: 800;
  color: var(--text-main);
}

.rotate-text,
.loading-text {
  font-size: clamp(14px, 2vw, 18px);
  color: var(--text-soft);
}

.screen-title {
  margin-bottom: 10px;
  font-size: clamp(28px, 4vw, 38px);
  font-weight: 800;
  color: var(--text-main);
}

.screen-text {
  font-size: 16px;
  line-height: 1.45;
  color: var(--text-soft);
}

.screen-button {
  margin-top: 18px;
  min-width: 180px;
  height: 54px;
  padding: 0 24px;
  border: 0;
  border-radius: 18px;
  font-size: 20px;
  font-weight: 800;
  color: #18202a;
  background:
    linear-gradient(180deg, rgba(255, 243, 204, 0.95), rgba(255, 195, 80, 0.98));
  box-shadow: 0 16px 30px rgba(4, 11, 18, 0.3);
}

.screen-button:active {
  transform: translateY(2px) scale(0.98);
}

.gift-screen {
  position: absolute;
  inset: 0;
  z-index: 13;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(circle at top right, rgba(255, 199, 126, 0.22), transparent 32%),
    rgba(4, 10, 17, 0.78);
  backdrop-filter: blur(20px);
}

.gift-card {
  width: min(1120px, 100%);
  max-height: min(86vh, 820px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 40%);
  gap: 22px;
  padding: 24px;
  border-radius: 28px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background:
    linear-gradient(135deg, rgba(13, 26, 39, 0.94), rgba(19, 39, 56, 0.9));
  box-shadow: 0 28px 62px rgba(0, 0, 0, 0.3);
}

.gift-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.gift-badge {
  margin-bottom: 12px;
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent-2);
}

.gift-title {
  font-size: clamp(28px, 4vw, 44px);
  line-height: 1;
  color: var(--text-main);
}

.gift-text {
  margin-top: 14px;
  max-width: 38ch;
  font-size: clamp(14px, 1.8vw, 18px);
  line-height: 1.55;
  color: var(--text-soft);
}

.gift-riddle {
  margin-top: 22px;
  padding: 18px;
  border-radius: 22px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(7, 16, 25, 0.42);
}

.gift-label {
  margin-bottom: 8px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--accent-2);
}

.gift-question {
  font-size: clamp(18px, 2.5vw, 26px);
  line-height: 1.35;
  color: var(--text-main);
}

.gift-answer-row {
  display: flex;
  gap: 12px;
  margin-top: 16px;
}

.gift-input {
  flex: 1;
  min-width: 0;
  height: 54px;
  padding: 0 16px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  font: inherit;
  font-size: 18px;
}

.gift-input::placeholder {
  color: rgba(248, 251, 255, 0.42);
}

.gift-submit,
.gift-primary,
.gift-secondary {
  height: 54px;
  padding: 0 20px;
  border: 0;
  border-radius: 16px;
  font-size: 17px;
  font-weight: 800;
  box-shadow: 0 16px 30px rgba(4, 11, 18, 0.3);
}

.gift-submit,
.gift-primary {
  color: #1a2430;
  background:
    linear-gradient(180deg, rgba(255, 243, 204, 0.95), rgba(255, 195, 80, 0.98));
}

.gift-secondary {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.gift-submit:disabled {
  opacity: 0.6;
}

.gift-feedback {
  margin-top: 12px;
  min-height: 1.5em;
  font-size: 14px;
  line-height: 1.45;
  color: rgba(248, 251, 255, 0.74);
}

.gift-feedback[data-tone="success"] {
  color: #bdf6a8;
}

.gift-feedback[data-tone="danger"] {
  color: #ffb1a2;
}

.gift-feedback[data-tone="warning"] {
  color: #ffe29d;
}

.gift-key {
  margin-top: 12px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 214, 104, 0.14);
  border: 1px solid rgba(255, 214, 104, 0.22);
  color: #fff3c7;
  font-size: clamp(18px, 2vw, 24px);
  line-height: 1.4;
  word-break: break-word;
}

.gift-actions {
  display: flex;
  gap: 12px;
  margin-top: auto;
  padding-top: 22px;
}

.gift-media {
  display: flex;
  align-items: stretch;
}

.gift-video {
  width: 100%;
  height: 100%;
  max-height: min(72vh, 720px);
  border-radius: 24px;
  background: rgba(0, 0, 0, 0.42);
  object-fit: cover;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.panic-toggle:active,
.music-toggle:active,
.gift-submit:active,
.gift-primary:active,
.gift-secondary:active {
  transform: translateY(2px) scale(0.98);
}

@media (orientation: portrait) {
  .rotate-device {
    display: flex;
  }
}

@media (orientation: landscape) {
  .rotate-device {
    display: none;
  }
}

@media (max-width: 920px) {
  .hud {
    flex-direction: column;
    align-items: stretch;
  }

  .hud-brand,
  .hud-stats {
    width: min(100%, 460px);
    max-width: none;
    min-width: 0;
  }

  .banner {
    top: auto;
    bottom: 110px;
    width: min(calc(100% - 28px), 420px);
    text-align: center;
  }

  .gift-card {
    grid-template-columns: 1fr;
    max-height: none;
    overflow: auto;
  }

  .gift-text {
    max-width: none;
  }

  .gift-video {
    max-height: 42vh;
  }
}

@media (max-width: 640px) {
  .gift-answer-row,
  .gift-actions {
    flex-direction: column;
  }

  .gift-submit,
  .gift-primary,
  .gift-secondary {
    width: 100%;
  }
}

@media (hover: hover) and (pointer: fine) {
  .touch-controls {
    opacity: 0.72;
  }
}
