/* All DOM surfaces, including native form controls, share the embedded pixel font. */
html, body { font-family: "PFStardust", sans-serif; }
button, input, select, textarea { font-family: inherit; }

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  background: #000;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

#game-wrap {
  position: relative;
  width: 960px;
  height: 540px;
  flex: 0 0 960px;
  transform-origin: center center;
  overflow: hidden;
}

canvas#game {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  background: #000;
  display: block;
}

/* C-021: 0~40 위쪽 자재 바 */
#ui-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 40px;
  display: flex;
  overflow: hidden;
  box-sizing: border-box;
  background: #111;
  border-bottom: 1px solid #333;
  pointer-events: auto;
  z-index: 10;
  scrollbar-width: none;
}

.tab-strip {
  flex: 0 0 auto;
  display: flex;
  overflow-x: auto;
  height: 40px;
  align-items: center;
  background: #111;
  border-right: 1px solid #333;
  scrollbar-width: none;
  width: 250px;
  min-width: 250px;
  box-sizing: border-box;
}

.tab {
  flex: 0 0 auto;
  padding: 0;
  justify-content: center;
  width: 50px;
  min-height: 40px;
  box-sizing: border-box;
  font: 15px PFStardust;
  color: #888;
  cursor: pointer;
  white-space: nowrap;
  user-select: none;
  border: none;
  background: transparent;
  border-right: 1px solid #222;
  height: 40px;
  display: flex;
  align-items: center;
}

.tab.active {
  color: #ffd166;
  background: #1a1a1a;
}

.tab:hover {
  color: #fff;
}

.materials-view {
  flex: 1 1 auto;
  display: flex;
  overflow-x: auto;
  align-items: center;
  gap: 2px;
  padding: 2px 4px;
  height: 40px;
  box-sizing: border-box;
  overflow-y: hidden;
  scrollbar-width: none;
  touch-action: pan-y;
  user-select: none;
  cursor: grab;
  font: 12px PFStardust;
  color: #eee;
  white-space: nowrap;
  min-width: 0;
}

.tab:disabled { color: #777; cursor: default; }
.tab-strip::-webkit-scrollbar,
.materials-view::-webkit-scrollbar { display: none; }
.materials-view:active { cursor: grabbing; }

.chip {
  flex: 0 0 100px;
  width: 100px;
  height: 36px;
  box-sizing: border-box;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  grid-template-rows: 15px 5px 12px;
  column-gap: 3px;
  padding: 1px;
  background: #1a1a1a;
  border: 1px solid #333;
}
.chip-icon {
  width: 32px;
  height: 32px;
  grid-column: 1;
  grid-row: 1 / 4;
  image-rendering: pixelated;
  object-fit: contain;
}
.chip-name {
  grid-column: 2;
  grid-row: 1;
  color: #ddd;
  white-space: nowrap;
  letter-spacing: -1px;
  font-size: 12px;
  line-height: 15px;
}
.chip-bar {
  grid-column: 2;
  grid-row: 2;
  height: 4px;
  background: #222;
  border: 1px solid #444;
  position: relative;
  box-sizing: border-box;
  overflow: hidden;
}

.chip-stock {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: #4a90e2;
  width: 0%;
}

.chip-needed {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.15);
  width: 0%;
  border-right: 1px dashed rgba(255, 255, 255, 0.4);
}

.chip-num {
  grid-column: 2;
  grid-row: 3;
  text-align: right;
  font-size: 9px;
  line-height: 10px;
  color: #aaa;
  white-space: nowrap;
}

/* C-021: 40~64 상태 줄 */
#ui-status {
  position: absolute;
  top: 40px;
  left: 0;
  right: 0;
  height: 24px;
  background: #0a0a0a;
  border-bottom: 1px solid #222;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 16px;
  font: 14px PFStardust;
  color: #eee;
  z-index: 10;
  box-sizing: border-box;
}

#ui-status > div {
  white-space: nowrap;
}

#ui-budget {
  color: #8ecaff;
}

#ui-satisfaction {
  color: #ff6b6b;
}

#ui-day {
  color: #ffd166;
  font-weight: bold;
}

/* C-021: 64~540 왼쪽 지도 영역(0~720) */
#map-area {
  position: absolute;
  top: 64px;
  left: 0;
  width: 720px;
  height: 476px;
  overflow: hidden;
  z-index: 1;
}

#map-canvas {
  display: block;
  image-rendering: pixelated;
}

/* C-021: 64~540 오른쪽 주문함(720~960) + 뉴스 */
#ui-right {
  position: absolute;
  top: 64px;
  left: 720px;
  width: 240px;
  height: 476px;
  background: #0a0a0a;
  border-left: 1px solid #222;
  display: flex;
  flex-direction: column;
  z-index: 1;
}

.orders-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
  font: 13px PFStardust;
  color: #eee;
}

.news-line {
  height: 30px;
  padding: 6px 8px;
  font: 13px PFStardust;
  color: #ffd166;
  border-top: 1px solid #222;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 시작 화면 제목(게임 시작 후 숨김) */
.title-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 50;
  cursor: pointer;
  color: #fff;
  font-family: PFStardust;
}

.title-text {
  font-size: 120px;
  font-weight: bold;
  margin-bottom: 24px;
}

.title-hint {
  font-size: 24px;
  color: #aaa;
}

/* T18: 폰 맞춤 — 버튼 최소 44px */
button {
  min-height: 44px;
  min-width: 44px;
  touch-action: manipulation;
}

/* 세로 화면 안내(폰 가로 방향 권장) */
#ui-portrait-alert {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: #000;
  color: #fff;
  font-family: PFStardust;
  display: none; /* 가로 방향이면 숨김 */
  align-items: center;
  justify-content: center;
  z-index: 9999;
  text-align: center;
  padding: 40px;
  box-sizing: border-box;
}

@media (max-width: 768px) and (orientation: portrait) {
  #ui-portrait-alert { display: flex; }
}

@font-face {
  font-family: "PFStardust";
  src: url("../assets/fonts/PFStardust.woff") format("woff");
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

#pause-button {
  position: absolute;
  top: 32px;
  left: 8px;
  width: 44px;
  height: 44px;
  background: #243047;
  color: #fff1d6;
  border: 1px solid #a9bcc7;
  font-family: inherit;
  cursor: pointer;
}
.order-list-card {
  display: block;
  width: 100%;
  min-height: 64px;
  padding: 8px;
  margin-bottom: 8px;
  color: #fff1d6;
  background: #243047;
  border: 1px solid #599ed1;
  text-align: left;
  white-space: pre-line;
  font: 14px/1.45 PFStardust, sans-serif;
  cursor: pointer;
}
.order-list-card:disabled {
  opacity: 1;
  cursor: default;
}
.orders-list h3 { margin: 4px 0 12px; }

/* PFStardust has generous native metrics: keep controls within the 540px stage. */
body, button { line-height: 1.25; }
#market-modal { line-height: 1.25; }
#market-modal h2 { font-size: 22px; line-height: 1.25; margin: 0 0 12px; }
#market-body button { line-height: 1.25; }
#market-message { font-size: 14px; margin: 8px 0; line-height: 1.25; }
#ending-screen { justify-content: flex-start !important; padding: 20px !important; line-height: 1.25; }
#ending-screen > div { flex-shrink: 0; }
#ending-screen > div:first-child { font-size: 36px !important; margin-bottom: 8px !important; }
#ending-screen > div:nth-child(2) { font-size: 16px !important; }
#ending-screen > div:nth-child(3) { display: grid; grid-template-columns: 1fr 1fr; column-gap: 28px; }
#ending-screen > div:nth-child(4) { font-size: 11px !important; }

/* Forecasts and delivery explanations remain readable on the fixed game canvas. */
.news-line {
  flex: 0 0 104px;
  height: 104px;
  box-sizing: border-box;
  white-space: normal;
  overflow-y: auto;
  line-height: 1.5;
}
#warehouse-button {
  position: absolute;
  top: 32px;
  left: 60px;
  height: 44px;
  padding: 0 10px;
  background: #243047;
  color: #fff1d6;
  border: 1px solid #a9bcc7;
  font: inherit;
  cursor: pointer;
}
#warehouse-panel button {
  min-height: 40px;
  padding: 6px 10px;
  font: inherit;
  background: #354353;
  color: #fff1d6;
  border: 1px solid #a9bcc7;
  cursor: pointer;
}
#warehouse-panel button:disabled { opacity: .45; cursor: default; }

#pause-state { color: #f4cf67; font-size: 14px; min-width: 76px; text-align: center; }
#warehouse-panel { font-size: 15px; line-height: 1.45; }
#warehouse-panel h2 { margin: 0 0 12px; font-size: 22px; }
#warehouse-panel p { margin: 8px 0; }
.order-list-card:disabled { border-color: #718b9f; color: #dce8ef; background: #263440; }
