* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #0b1020;
  color: #fff;
}

#game {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

#minimap {
  position: fixed;
  top: 82px;
  right: 20px;
  width: 160px;
  height: 160px;
  z-index: 5;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(10, 15, 35, 0.6);
  backdrop-filter: blur(4px);
  pointer-events: none;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

#minimap.hidden {
  display: none;
}

#hud {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  pointer-events: none;
  z-index: 5;
  font-variant-numeric: tabular-nums;
}

#hud #menu-btn {
  pointer-events: auto;
  margin-left: auto;
}

.stat {
  display: flex;
  align-items: baseline;
  gap: 8px;
  background: rgba(0, 0, 0, 0.45);
  padding: 8px 16px;
  border-radius: 999px;
  backdrop-filter: blur(6px);
}

.stat > span:first-child {
  font-size: 26px;
  font-weight: 800;
  color: #ffd94d;
}

.stat .label {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #c9d2e8;
}

#menu-btn {
  font-size: 15px;
  font-weight: 700;
  color: #c9d2e8;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(201, 210, 232, 0.35);
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
  backdrop-filter: blur(6px);
  transition: background 0.12s ease, color 0.12s ease;
}

#menu-btn:hover {
  background: #ffd94d;
  color: #1a1405;
}

#stamina {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.45);
  padding: 8px 16px;
  border-radius: 999px;
  backdrop-filter: blur(6px);
  z-index: 5;
  pointer-events: none;
}

#stamina-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #c9d2e8;
}

#stamina-track {
  width: 140px;
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  overflow: hidden;
}

#stamina-bar {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #4ade80, #ffd94d);
  transition: width 0.1s linear;
}

#stamina-bar.low {
  background: linear-gradient(90deg, #f87171, #ffd94d);
}

#hotbar {
  position: fixed;
  left: 50%;
  bottom: 78px;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  z-index: 5;
  pointer-events: none;
}

.hot-slot {
  position: relative;
  width: 58px;
  height: 58px;
  border: 2px solid rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  color: #fff;
  transition: border-color 0.12s ease, transform 0.12s ease;
}

.hot-slot .key {
  position: absolute;
  top: 4px;
  left: 6px;
  font-size: 11px;
  color: #c9d2e8;
  font-weight: 700;
}

.hot-slot .count {
  position: absolute;
  bottom: 3px;
  right: 7px;
  font-size: 14px;
  font-weight: 800;
  color: #ffd94d;
}

.hot-slot.selected {
  border-color: #ffd94d;
  transform: translateY(-4px);
  box-shadow: 0 4px 18px rgba(255, 217, 77, 0.35);
}

.hot-slot.empty {
  opacity: 0.35;
}

#main-menu {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #464646;
  z-index: 10;
  padding: 0;
}

#main-menu.hidden {
  display: none;
}

.menu-bg {
  position: absolute;
  inset: 0;
  background: url("menu-bg.png") center / cover no-repeat;
  pointer-events: none;
}

#menu-maze {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(100%, 460px);
  height: min(100%, 460px);
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
}

.menu-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  text-align: center;
  z-index: 1;
  width: 100%;
  max-width: 380px;
  padding: 24px;
}

.menu-inner h1 {
  font-size: 52px;
  letter-spacing: 6px;
  color: #f5c518;
  text-shadow: 0 0 40px rgba(245, 197, 24, 0.35);
  margin-bottom: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-weight: 900;
}

#diff-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#diff-panel button {
  font-size: 13px;
  font-weight: 700;
  color: #b0b0b0;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 7px 20px;
  border-radius: 4px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 1px;
  transition: background 0.12s ease, color 0.12s ease;
}

#diff-panel button.active {
  background: #f5c518;
  color: #1a1a1a;
  border-color: #f5c518;
}

#main-play {
  margin-top: 18px;
  font-size: 28px;
  font-weight: 900;
  color: #fff;
  background: #d32f2f;
  border: none;
  padding: 14px 64px;
  border-radius: 6px;
  cursor: pointer;
  letter-spacing: 3px;
  text-transform: uppercase;
  box-shadow: 0 6px 28px rgba(211, 47, 47, 0.4);
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
  width: 100%;
}

#main-play:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 36px rgba(211, 47, 47, 0.55);
  background: #e53935;
}

#main-play:active {
  transform: translateY(0);
}

#main-tutorial {
  font-size: 13px;
  font-weight: 700;
  color: #999;
  background: none;
  border: 1px solid rgba(255, 255, 255, 0.12);
  padding: 8px 20px;
  border-radius: 4px;
  cursor: pointer;
  letter-spacing: 1px;
  text-transform: uppercase;
  transition: color 0.12s ease, border-color 0.12s ease;
}

#main-tutorial:hover {
  color: #ccc;
  border-color: rgba(255, 255, 255, 0.3);
}

.controls-hint {
  display: flex;
  gap: 16px;
  margin-top: 4px;
  color: #777;
  font-size: 12px;
  letter-spacing: 0.5px;
}

.controls-hint b {
  color: #aaa;
}

#overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: rgba(6, 10, 24, 0.72);
  backdrop-filter: blur(8px);
  text-align: center;
  z-index: 10;
  padding: 24px;
}

#overlay.hidden {
  display: none;
}

#overlay h1 {
  font-size: 56px;
  letter-spacing: 2px;
  color: #ffd94d;
  text-shadow: 0 4px 24px rgba(255, 217, 77, 0.35);
}

#overlay p {
  color: #c9d2e8;
  font-size: 17px;
  max-width: 420px;
  line-height: 1.4;
}

#overlay button {
  font-size: 20px;
  font-weight: 700;
  color: #1a1405;
  background: #ffd94d;
  border: none;
  padding: 14px 46px;
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  box-shadow: 0 8px 30px rgba(255, 217, 77, 0.3);
}

#overlay button:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 36px rgba(255, 217, 77, 0.45);
}

#overlay button:active {
  transform: translateY(0);
}

#overlay-result {
  font-size: 28px;
  font-weight: 800;
}

#main-tutorial {
  margin-top: -6px;
  font-size: 16px;
  font-weight: 700;
  color: #c9d2e8;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(201, 210, 232, 0.35);
  padding: 12px 40px;
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: 1px;
  box-shadow: none;
  transition: background 0.12s ease, color 0.12s ease, transform 0.12s ease;
}

#main-tutorial:hover {
  background: #ffd94d;
  color: #1a1405;
  transform: translateY(-2px);
}

#tutorial {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 10, 24, 0.78);
  backdrop-filter: blur(8px);
  z-index: 20;
  padding: 24px;
  overflow: auto;
}

#tutorial.hidden {
  display: none;
}

.tutorial-inner {
  width: 100%;
  max-width: 540px;
  background: rgba(20, 30, 70, 0.9);
  border: 1px solid rgba(255, 217, 77, 0.4);
  border-radius: 22px;
  padding: 30px 32px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.tutorial-inner h2 {
  font-size: 32px;
  color: #ffd94d;
  text-align: center;
  margin-bottom: 18px;
  letter-spacing: 1px;
}

.tutorial-body {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tutorial-section h3 {
  font-size: 15px;
  color: #4dd7ff;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.tutorial-section p {
  font-size: 15px;
  color: #c9d2e8;
  line-height: 1.5;
}

.tutorial-section b {
  color: #ffd94d;
}

#tutorial-close {
  display: block;
  margin: 22px auto 0;
  font-size: 18px;
  font-weight: 700;
  color: #1a1405;
  background: #ffd94d;
  border: none;
  padding: 13px 44px;
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

#tutorial-close:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 36px rgba(255, 217, 77, 0.45);
}

#store-result {
  color: #ffd94d;
  font-size: 16px;
  font-weight: 800;
  text-align: center;
}

#store-result.hidden {
  display: none;
}

#door-hint {
  position: fixed;
  top: 86px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(34, 255, 136, 0.5);
  color: #9dffc9;
  padding: 10px 22px;
  border-radius: 999px;
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  pointer-events: none;
  backdrop-filter: blur(6px);
}

#store-ui {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%);
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(34, 255, 136, 0.5);
  border-radius: 18px;
  padding: 16px 24px;
  backdrop-filter: blur(8px);
  pointer-events: auto;
}

#store-ui.hidden {
  display: none;
}

#store-points {
  font-size: 30px;
  font-weight: 800;
  color: #4ade80;
}

.store-row {
  display: flex;
  gap: 12px;
}

#store-ui button {
  font-size: 16px;
  font-weight: 700;
  color: #0c2b1c;
  background: #4ade80;
  border: none;
  padding: 12px 20px;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease;
}

#store-ui button:hover {
  transform: translateY(-2px);
  background: #6ee7a0;
}

#store-ui button:disabled {
  opacity: 0.4;
  cursor: default;
  transform: none;
}

#store-hint {
  color: #9dffc9;
  font-size: 13px;
  opacity: 0.85;
}

#book {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 10, 24, 0.78);
  backdrop-filter: blur(8px);
  z-index: 15;
  padding: 24px;
}

#book.hidden {
  display: none;
}

.book-inner {
  width: 100%;
  max-width: 440px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: linear-gradient(180deg, #201605, #2b1f08);
  border: 2px solid #c9a24d;
  border-radius: 10px 30px 30px 10px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6), inset 0 0 50px rgba(201, 162, 77, 0.12);
  padding: 30px 32px;
}

.book-inner h2 {
  font-size: 28px;
  letter-spacing: 2px;
  color: #c9a24d;
  text-align: center;
  font-family: Georgia, "Times New Roman", serif;
  border-bottom: 1px solid rgba(201, 162, 77, 0.4);
  padding-bottom: 12px;
}

.book-sub {
  color: #b08f3e;
  font-size: 14px;
  text-align: center;
  font-style: italic;
}

#book-list {
  list-style: none;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
  max-height: 44vh;
}

#book-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(201, 162, 77, 0.35);
  border-radius: 999px;
  padding: 6px 14px 6px 6px;
}

#book-list img {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid #c9a24d;
  flex: none;
}

#book-list .name {
  font-weight: 700;
  color: #ffe9b0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#book-list .you {
  margin-left: auto;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #ffd94d;
  background: rgba(255, 217, 77, 0.15);
  border: 1px solid rgba(255, 217, 77, 0.5);
  padding: 3px 10px;
  border-radius: 999px;
}

#book-list .book-empty {
  justify-content: center;
  color: #b08f3e;
  font-style: italic;
  font-size: 15px;
  padding: 16px;
}

#book-close {
  font-size: 17px;
  font-weight: 700;
  color: #1a1405;
  background: #c9a24d;
  border: none;
  padding: 12px 44px;
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: 1px;
  margin: 4px auto 0;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

#main-tutorial {
  margin-top: -6px;
  font-size: 16px;
  font-weight: 700;
  color: #c9d2e8;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(201, 210, 232, 0.35);
  padding: 12px 40px;
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: 1px;
  box-shadow: none;
  transition: background 0.12s ease, color 0.12s ease, transform 0.12s ease;
}

#main-achievements {
  font-size: 14px;
  font-weight: 700;
  color: #ffd94d;
  background: none;
  border: 1px solid rgba(245, 197, 24, 0.4);
  padding: 9px 24px;
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: 1px;
  text-transform: uppercase;
  transition: background 0.12s ease, color 0.12s ease, transform 0.12s ease;
}

#main-achievements:hover {
  background: #ffd94d;
  color: #1a1405;
  transform: translateY(-2px);
}

#book-close:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(201, 162, 77, 0.4);
}

#ach-toast {
  position: fixed;
  top: 82px;
  left: 50%;
  transform: translate(-50%, 0);
  z-index: 30;
  background: linear-gradient(90deg, #3a2d00, #5d4a00);
  border: 1px solid #f5c518;
  color: #ffe9a3;
  padding: 12px 26px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.5px;
  box-shadow: 0 10px 34px rgba(245, 197, 24, 0.35);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
  white-space: nowrap;
  backdrop-filter: blur(6px);
}

#ach-toast.show {
  opacity: 1;
}

#achievements {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 10, 24, 0.78);
  backdrop-filter: blur(8px);
  z-index: 15;
  padding: 24px;
}

#achievements.hidden {
  display: none;
}

.ach-inner {
  width: 100%;
  max-width: 440px;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: rgba(20, 30, 70, 0.95);
  border: 1px solid rgba(245, 197, 24, 0.5);
  border-radius: 22px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
  padding: 28px 30px;
}

.ach-inner h2 {
  font-size: 30px;
  letter-spacing: 1px;
  color: #ffd94d;
  text-align: center;
  font-weight: 900;
}

.ach-sub {
  color: #c9d2e8;
  font-size: 14px;
  text-align: center;
  opacity: 0.85;
}

#ach-list {
  list-style: none;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
}

#ach-list li {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(245, 197, 24, 0.35);
  border-radius: 14px;
  padding: 12px 14px;
}

#ach-list li.locked {
  opacity: 0.45;
  border-color: rgba(255, 255, 255, 0.12);
}

#ach-list .icon {
  font-size: 28px;
  flex: none;
  width: 40px;
  text-align: center;
}

#ach-list .body {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#ach-list .name {
  font-weight: 800;
  color: #ffe9a0;
}

#ach-list li.locked .name {
  color: #c9d2e8;
}

#ach-list .desc {
  font-size: 13px;
  color: #c9d2e8;
}

#ach-list .check {
  margin-left: auto;
  font-size: 20px;
  font-weight: 900;
  color: #4ade80;
  flex: none;
}

#ach-close {
  font-size: 17px;
  font-weight: 700;
  color: #1a1405;
  background: #ffd94d;
  border: none;
  padding: 12px 44px;
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: 1px;
  margin: 4px auto 0;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

#ach-close:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(255, 217, 77, 0.4);
}

#main-make {
  margin-top: -6px;
  font-size: 16px;
  font-weight: 700;
  color: #1a1405;
  background: #f5c518;
  border: 1px solid rgba(245, 197, 24, 0.6);
  padding: 12px 40px;
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: 1px;
  text-transform: uppercase;
  box-shadow: 0 6px 24px rgba(245, 197, 24, 0.35);
  transition: background 0.12s ease, color 0.12s ease, transform 0.12s ease;
}

#main-make:hover {
  background: #ffd94d;
  color: #7a5d00;
  transform: translateY(-2px);
}

#make-level {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6, 10, 24, 0.78);
  backdrop-filter: blur(8px);
  z-index: 20;
  padding: 24px;
  overflow: auto;
}

#make-level.hidden {
  display: none;
}

.make-inner {
  width: 100%;
  max-width: 440px;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: rgba(20, 30, 70, 0.92);
  border: 1px solid rgba(245, 197, 24, 0.5);
  border-radius: 22px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
  padding: 28px 30px;
  overflow-y: auto;
}

.make-inner h2 {
  font-size: 32px;
  letter-spacing: 1px;
  color: #ffd94d;
  text-align: center;
  font-weight: 900;
}

.make-sub {
  color: #c9d2e8;
  font-size: 13px;
  text-align: center;
  opacity: 0.85;
}

#make-groups {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.make-group {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  padding: 12px 14px;
}

.make-label {
  font-weight: 700;
  color: #c9d2e8;
  font-size: 15px;
}

.make-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.make-step {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  border: none;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  font-size: 18px;
  font-weight: 800;
  cursor: pointer;
  line-height: 1;
}

.make-step:hover {
  background: #ffd94d;
  color: #1a1405;
}

.make-val {
  min-width: 44px;
  text-align: center;
  font-size: 16px;
  font-weight: 800;
  color: #ffd94d;
  font-variant-numeric: tabular-nums;
}

.make-cycle {
  font-size: 13px;
  font-weight: 800;
  color: #1a1405;
  background: #f5c518;
  border: 1px solid rgba(245, 197, 24, 0.6);
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: 1px;
  text-transform: uppercase;
  transition: background 0.12s ease, transform 0.12s ease;
}

.make-cycle:hover {
  background: #ffd94d;
  transform: translateY(-1px);
}

.make-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

#make-play {
  width: 100%;
  font-size: 20px;
  font-weight: 800;
  color: #1a1405;
  background: #ffd94d;
  border: none;
  padding: 14px 46px;
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: 1px;
  box-shadow: 0 8px 30px rgba(255, 217, 77, 0.3);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}

#make-play:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 36px rgba(255, 217, 77, 0.45);
}

#make-reset,
#make-close {
  width: 100%;
  font-size: 14px;
  font-weight: 700;
  color: #c9d2e8;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(201, 210, 232, 0.35);
  padding: 11px 30px;
  border-radius: 999px;
  cursor: pointer;
  letter-spacing: 1px;
}

#make-reset:hover,
#make-close:hover {
  background: #ffd94d;
  color: #1a1405;
}
