/* ===== เกมสร้างเมือง 3D — HUD styles ===== */

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #0e1420;
  font-family: system-ui, -apple-system, 'Sukhumvit Set', 'Noto Sans Thai',
    'Segoe UI', sans-serif;
  color: #ffffff;
}

/* พื้นที่เกม — เต็มจอ */
#app {
  position: fixed;
  inset: 0;
  z-index: 0;
}

#app canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ===== HUD overlay ===== */
#hud {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none; /* ให้คลิกทะลุไปที่เกม ยกเว้น element ที่เปิดไว้ */
}

.hud-panel {
  position: absolute;
  background: rgba(15, 20, 32, 0.62);
  backdrop-filter: blur(12px) saturate(140%);
  -webkit-backdrop-filter: blur(12px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  padding: 14px 18px;
  color: #fff;
}

.hud-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.55);
  margin-bottom: 4px;
}

/* ---- แผงซ้ายบน: ของที่ต้องวางตอนนี้ + คิวถัดไป ---- */
.hud-top-left {
  top: 20px;
  left: 20px;
  min-width: 220px;
  max-width: 320px;
}

.hud-current {
  font-size: 1.7rem;
  font-weight: 700;
  line-height: 1.25;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.hud-label-queue {
  margin-top: 12px;
}

.hud-queue {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 26px;
}

.queue-chip {
  display: inline-block;
  padding: 4px 12px;
  font-size: 0.82rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.9);
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  white-space: nowrap;
}

/* ---- แผงขวาบน: จำนวนที่วางแล้ว ---- */
.hud-top-right {
  top: 20px;
  right: 20px;
  text-align: right;
  min-width: 110px;
}

.hud-count-row {
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  gap: 6px;
}

.hud-count {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  color: #7dd3fc;
  text-shadow: 0 2px 10px rgba(125, 211, 252, 0.35);
}

.hud-count-unit {
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.6);
}

/* ---- ปุ่มถ่ายรูป: ขวาล่าง ---- */
.hud-capture {
  position: absolute;
  right: 24px;
  bottom: 24px;
  pointer-events: auto;
  cursor: pointer;

  font-family: inherit;
  font-size: 1.1rem;
  font-weight: 700;
  color: #0e1420;

  padding: 14px 26px;
  border: none;
  border-radius: 999px;
  background: linear-gradient(135deg, #7dd3fc 0%, #38bdf8 100%);
  box-shadow: 0 6px 20px rgba(56, 189, 248, 0.45);

  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.hud-capture:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 10px 28px rgba(56, 189, 248, 0.55);
  filter: brightness(1.05);
}

.hud-capture:active {
  transform: translateY(0) scale(0.97);
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.4);
}

/* เอฟเฟกต์แฟลชตอนถ่ายรูป */
.hud-capture.flash {
  animation: capture-flash 0.35s ease;
}

@keyframes capture-flash {
  0% {
    filter: brightness(1);
  }
  30% {
    filter: brightness(1.8);
    box-shadow: 0 0 36px rgba(255, 255, 255, 0.9);
  }
  100% {
    filter: brightness(1);
  }
}

/* ---- คำแนะนำ: กลางล่าง ---- */
.hud-help {
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  padding: 8px 20px;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.75);
  border-radius: 999px;
  white-space: nowrap;
}

/* ---- จอเล็ก ---- */
@media (max-width: 640px) {
  .hud-top-left {
    min-width: 170px;
    padding: 10px 14px;
  }

  .hud-current {
    font-size: 1.3rem;
  }

  .hud-help {
    font-size: 0.72rem;
    max-width: calc(100vw - 32px);
    white-space: normal;
    text-align: center;
  }

  .hud-capture {
    font-size: 1rem;
    padding: 12px 20px;
  }
}

/* ===== หน้าจอเลือกธีม ===== */
#theme-select {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(56, 189, 248, 0.18), transparent 60%),
    rgba(10, 14, 24, 0.88);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 1;
  transition: opacity 0.4s ease;
}

#theme-select.closing {
  opacity: 0;
  pointer-events: none;
}

.theme-panel {
  max-width: 720px;
  width: 100%;
  text-align: center;
}

.theme-title {
  font-size: 2.1rem;
  font-weight: 800;
  text-shadow: 0 4px 18px rgba(0, 0, 0, 0.5);
}

.theme-sub {
  margin-top: 8px;
  margin-bottom: 28px;
  font-size: 0.95rem;
  color: rgba(255, 255, 255, 0.65);
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.theme-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 22px 12px 18px;
  cursor: pointer;

  font-family: inherit;
  color: #fff;

  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 20px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);

  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease,
    box-shadow 0.15s ease;
}

.theme-card:hover {
  transform: translateY(-4px) scale(1.03);
  background: rgba(125, 211, 252, 0.14);
  border-color: rgba(125, 211, 252, 0.55);
  box-shadow: 0 14px 34px rgba(56, 189, 248, 0.3);
}

.theme-card:active {
  transform: translateY(-1px) scale(0.99);
}

.theme-card-emoji {
  font-size: 2.6rem;
  line-height: 1;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.4));
}

.theme-card-name {
  font-size: 1.15rem;
  font-weight: 700;
}

.theme-card-count {
  font-size: 0.78rem;
  color: rgba(255, 255, 255, 0.55);
}

@media (max-width: 640px) {
  .theme-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .theme-title {
    font-size: 1.5rem;
  }

  .theme-card-emoji {
    font-size: 2.1rem;
  }
}
