/* ============ ピクセルゲーム工房物語 - グローバルスタイル ============ */
* { margin: 0; padding: 0; box-sizing: border-box; user-select: none; -webkit-user-select: none; }

:root {
  --ink: #221a2e;
  --paper: #f4e9d0;
  --paper-dark: #e2d3b3;
  --accent: #e8663c;
  --accent2: #3c9be8;
  --good: #3aa655;
  --bad: #d8433c;
  --gold: #e8b23c;
  --c-fun: #e8663c;
  --c-innov: #9b59d0;
  --c-art: #3c9be8;
  --c-sound: #3aa655;
}

html, body { height: 100%; }
body {
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", "Meiryo", "Noto Sans JP", system-ui, sans-serif;
  background: #1a1426;
  background-image:
    linear-gradient(rgba(255,255,255,.025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.025) 1px, transparent 1px);
  background-size: 24px 24px;
  color: var(--ink);
  overflow: hidden;
}

#app { width: 100%; height: 100vh; display: flex; flex-direction: column; }
.hidden { display: none !important; }
.screen { width: 100%; height: 100%; }

/* ============ ボタン ============ */
.pbtn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 4px;
  padding: 6px 12px;
  cursor: pointer;
  box-shadow: 0 4px 0 var(--ink);
  transition: transform .06s, box-shadow .06s, filter .1s;
  touch-action: manipulation;
}
.pbtn:hover:not(:disabled) { filter: brightness(1.06); }
.pbtn:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 0 0 var(--ink); }
.pbtn:disabled { opacity: .45; cursor: not-allowed; }
.pbtn-primary { background: var(--accent); color: #fff; }
.pbtn-blue { background: var(--accent2); color: #fff; }
.pbtn-danger { background: var(--bad); color: #fff; }
.pbtn-big { font-size: 20px; padding: 12px 40px; min-width: 260px; }
.pbtn-close { padding: 2px 9px; font-size: 14px; box-shadow: 0 3px 0 var(--ink); background: var(--bad); color: #fff; }

/* ============ タイトル画面 ============ */
#screen-title {
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(ellipse at 50% 30%, #3a2b55 0%, #1a1426 70%);
  position: relative;
}
#screen-title::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image:
    radial-gradient(#ffffff22 1.5px, transparent 1.5px),
    radial-gradient(#ffffff14 1px, transparent 1px);
  background-size: 90px 90px, 47px 47px;
  background-position: 10px 20px, 30px 60px;
}
.title-inner { text-align: center; position: relative; animation: titleFloat 4s ease-in-out infinite; }
@keyframes titleFloat { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
.title-logo-top {
  color: var(--gold); letter-spacing: 8px; font-size: 14px; font-weight: 700; margin-bottom: 10px;
  text-shadow: 2px 2px 0 #000;
}
.title-logo-main {
  font-size: 72px; color: #fff; letter-spacing: 10px; font-weight: 900;
  text-shadow:
    4px 4px 0 var(--accent),
    8px 8px 0 var(--ink),
    0 0 40px rgba(232,102,60,.5);
}
.title-logo-deco { margin-top: 18px; font-size: 26px; letter-spacing: 18px; }
.title-logo-deco span { display: inline-block; animation: bounce 1.6s ease-in-out infinite; }
.title-logo-deco span:nth-child(2) { animation-delay: .15s; }
.title-logo-deco span:nth-child(3) { animation-delay: .3s; }
.title-logo-deco span:nth-child(4) { animation-delay: .45s; }
.title-logo-deco span:nth-child(5) { animation-delay: .6s; }
@keyframes bounce { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-9px); } }
.title-menu { margin-top: 46px; display: flex; flex-direction: column; gap: 18px; align-items: center; }
.title-footer { margin-top: 40px; color: #9d8fc0; font-size: 13px; letter-spacing: 3px; }

/* ============ ゲームレイアウト ============ */
#screen-game { display: flex; flex-direction: column; padding: 10px 12px 8px; gap: 8px; }
#game-layout { flex: 1; display: flex; gap: 10px; min-height: 0; }

#left-col { flex: 1.5; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
#office-frame {
  flex: 1; min-height: 0;
  background: #120e1c;
  border: 4px solid var(--ink);
  border-radius: 6px;
  box-shadow: 0 6px 0 rgba(0,0,0,.4), inset 0 0 60px rgba(0,0,0,.5);
  display: flex; flex-direction: column;
  overflow: hidden;
  position: relative;
}
#office-topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 5px 12px;
  background: linear-gradient(#3a2b55, #2a1f40);
  border-bottom: 3px solid var(--ink);
  color: #f4e9d0; font-size: 13px; font-weight: 700; letter-spacing: 1px;
  flex: none;
}
#office-mode { color: var(--gold); }
#office-canvas {
  flex: 1; min-height: 0;
  width: 100%; height: 100%;
  object-fit: contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  display: block;
}
#hint-box {
  flex: none;
  background: #2a2140;
  border: 3px solid var(--ink);
  border-radius: 5px;
  padding: 8px 12px;
  color: #ffe9a8;
  font-size: 13px;
  display: flex; gap: 8px; align-items: center;
  box-shadow: 0 4px 0 rgba(0,0,0,.35);
}
#hint-icon { animation: hintPulse 1.4s ease-in-out infinite; }
@keyframes hintPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.25); } }

#right-col { width: 350px; flex: none; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }

.panel {
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 6px;
  box-shadow: 0 4px 0 rgba(0,0,0,.35);
  padding: 9px 12px;
  flex: none;
}
.panel-title { font-weight: 800; font-size: 14px; margin-bottom: 6px; letter-spacing: 1px; }

.info-row { display: flex; justify-content: space-between; padding: 2px 0; font-size: 14px; }
.info-label { font-weight: 700; color: #6b5c45; }
.info-value { font-weight: 800; font-variant-numeric: tabular-nums; }
.money-good { color: var(--good); }
.money-bad { color: var(--bad); animation: blinkBad 1s steps(2) infinite; }
@keyframes blinkBad { 50% { opacity: .35; } }

#speed-ctrl { display: flex; gap: 6px; margin-top: 8px; }
.pbtn-speed { flex: 1; padding: 4px 0; font-size: 12px; box-shadow: 0 3px 0 var(--ink); }
.pbtn-speed.active { background: var(--gold); }

/* プロジェクトパネル */
.proj-phase-row { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.phase-tag {
  background: var(--accent2); color: #fff; font-size: 12px; font-weight: 800;
  border: 2px solid var(--ink); border-radius: 3px; padding: 1px 8px;
}
.proj-week { font-size: 12px; font-weight: 700; color: #6b5c45; }
.bar-outer {
  height: 16px; background: #4a3d2e; border: 2px solid var(--ink); border-radius: 3px;
  overflow: hidden; position: relative;
}
.bar-slim { height: 11px; flex: 1; }
.bar-fill { height: 100%; width: 0%; transition: width .35s ease-out; border-radius: 1px; }
.bar-progress { background: repeating-linear-gradient(45deg, var(--gold), var(--gold) 8px, #f5c96a 8px, #f5c96a 16px); }
.bar-contract { background: repeating-linear-gradient(45deg, var(--accent2), var(--accent2) 8px, #6cb4ef 8px, #6cb4ef 16px); }
.bg-fun { background: var(--c-fun); }
.bg-innov { background: var(--c-innov); }
.bg-art { background: var(--c-art); }
.bg-sound { background: var(--c-sound); }
.c-fun { color: var(--c-fun); } .c-innov { color: var(--c-innov); }
.c-art { color: var(--c-art); } .c-sound { color: var(--c-sound); }

.proj-stats { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.pstat { display: flex; align-items: center; gap: 6px; }
.pstat-name { width: 34px; font-size: 12px; font-weight: 800; flex: none; }
.pstat-val { width: 34px; text-align: right; font-size: 12px; font-weight: 800; flex: none; font-variant-numeric: tabular-nums; }

.proj-bottom { display: flex; justify-content: space-between; margin-top: 7px; font-size: 13px; font-weight: 800; }
.bug-tag { color: var(--bad); }
.point-tag { color: #8a6d1f; }
.boost-row { display: flex; gap: 5px; margin-top: 7px; }
.boost-btn { flex: 1; padding: 4px 0; font-size: 12px; box-shadow: 0 3px 0 var(--ink); }
.boost-note { font-size: 11px; color: #8a7a5e; margin-top: 5px; text-align: center; }

.contract-text { font-size: 12px; font-weight: 700; color: #6b5c45; margin-top: 5px; }

/* セールスパネル */
.sale-item { font-size: 12px; padding: 4px 0; border-bottom: 1px dashed #c9b791; }
.sale-item:last-child { border-bottom: none; }
.sale-name { font-weight: 800; }
.sale-detail { color: #6b5c45; display: flex; justify-content: space-between; margin-top: 2px; }

/* スタッフパネル */
#staff-list { display: flex; flex-direction: column; gap: 5px; max-height: 240px; overflow-y: auto; }
.staff-item {
  display: flex; align-items: center; gap: 8px;
  background: var(--paper-dark); border: 2px solid var(--ink); border-radius: 4px;
  padding: 4px 8px; font-size: 12px;
}
.staff-avatar { width: 26px; height: 26px; image-rendering: pixelated; flex: none; border: 2px solid var(--ink); border-radius: 3px; background: #cfe3f7; }
.staff-main { flex: 1; min-width: 0; }
.staff-name-row { display: flex; justify-content: space-between; font-weight: 800; }
.staff-role { color: #6b5c45; font-size: 11px; font-weight: 700; }
.staff-energy-bar { height: 6px; background: #4a3d2e; border: 1px solid var(--ink); border-radius: 2px; overflow: hidden; margin-top: 3px; }
.staff-energy-fill { height: 100%; background: var(--good); }
.staff-energy-fill.low { background: var(--bad); }

/* ============ 下部アクションバー ============ */
#action-bar {
  flex: none;
  display: flex; gap: 8px; justify-content: center;
  padding: 6px 4px 10px;
}
.abtn {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 92px; padding: 7px 10px;
  font-size: 20px;
  background: var(--paper);
}
.abtn i { font-style: normal; font-size: 12px; font-weight: 800; letter-spacing: 1px; }
.abtn.pulse { animation: abtnPulse 1.2s ease-in-out infinite; }
@keyframes abtnPulse { 0%,100% { background: var(--paper); } 50% { background: #ffe08c; } }

/* ============ モーダル ============ */
#modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(10,6,20,.72);
  display: flex; align-items: center; justify-content: center;
  animation: fadeIn .15s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
#modal-box {
  width: min(720px, 94vw);
  max-height: 88vh;
  background: var(--paper);
  border: 4px solid var(--ink);
  border-radius: 8px;
  box-shadow: 0 8px 0 rgba(0,0,0,.5), 0 0 80px rgba(232,178,60,.15);
  display: flex; flex-direction: column;
  animation: popIn .18s cubic-bezier(.34,1.56,.64,1);
}
@keyframes popIn { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
#modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px;
  background: linear-gradient(#3a2b55, #2a1f40);
  border-bottom: 3px solid var(--ink);
  border-radius: 4px 4px 0 0;
  color: #fff; font-weight: 900; font-size: 17px; letter-spacing: 2px;
}
#modal-body { padding: 14px 16px; overflow-y: auto; font-size: 14px; line-height: 1.65; }
#modal-actions { display: flex; gap: 10px; justify-content: center; padding: 10px 16px 16px; flex-wrap: wrap; }

/* モーダル内コンポーネント */
.grid-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.sel-card {
  border: 3px solid var(--ink); border-radius: 5px; background: #fff;
  padding: 8px 10px; cursor: pointer; text-align: center;
  box-shadow: 0 3px 0 rgba(0,0,0,.25);
  transition: transform .07s;
  position: relative;
}
.sel-card:hover:not(.locked) { transform: translateY(-2px); }
.sel-card.selected { background: #ffe08c; outline: 3px solid var(--accent); }
.sel-card.locked { background: #cfc4ad; color: #8a7a5e; cursor: pointer; }
.sel-card .sc-emoji { font-size: 22px; }
.sel-card .sc-name { font-weight: 800; font-size: 14px; }
.sel-card .sc-sub { font-size: 11px; color: #6b5c45; margin-top: 2px; }
.sel-card .sc-badge {
  position: absolute; top: -8px; right: -6px;
  background: var(--gold); border: 2px solid var(--ink); border-radius: 3px;
  font-size: 10px; font-weight: 800; padding: 0 5px;
}

.wizard-steps { display: flex; gap: 6px; margin-bottom: 12px; }
.wstep {
  flex: 1; text-align: center; font-size: 12px; font-weight: 800;
  padding: 4px 0; border: 2px solid var(--ink); border-radius: 4px;
  background: var(--paper-dark); color: #8a7a5e;
}
.wstep.active { background: var(--accent); color: #fff; }
.wstep.done { background: var(--good); color: #fff; }

.name-input {
  font-family: inherit; font-size: 17px; font-weight: 800;
  border: 3px solid var(--ink); border-radius: 5px; padding: 7px 12px;
  width: 100%; background: #fff; color: var(--ink);
}
.name-input:focus { outline: 3px solid var(--gold); }

.kv-table { width: 100%; border-collapse: collapse; }
.kv-table td { padding: 4px 6px; border-bottom: 1px dashed #c9b791; }
.kv-table td:first-child { font-weight: 800; color: #6b5c45; width: 40%; }

.staff-card {
  display: flex; gap: 10px; align-items: center;
  border: 3px solid var(--ink); border-radius: 6px;
  background: #fff; padding: 8px 12px; margin-bottom: 8px;
  box-shadow: 0 3px 0 rgba(0,0,0,.2);
}
.staff-card.selected { background: #ffe08c; outline: 3px solid var(--accent); }
.staff-card .sc-canvas { width: 40px; height: 40px; image-rendering: pixelated; border: 2px solid var(--ink); border-radius: 4px; background: #cfe3f7; flex: none; }
.staff-card .sc-info { flex: 1; min-width: 0; }
.staff-card .sc-title { font-weight: 900; font-size: 15px; }
.staff-card .sc-attrs { display: flex; gap: 10px; font-size: 12px; font-weight: 700; color: #4a3d2e; flex-wrap: wrap; margin-top: 3px; }
.staff-card .sc-side { text-align: right; flex: none; }

.attr-chip { white-space: nowrap; }
.attr-chip b { font-size: 13px; }

.review-box { text-align: center; padding: 8px 0; }
.review-row {
  display: flex; align-items: center; justify-content: space-between;
  background: #fff; border: 3px solid var(--ink); border-radius: 5px;
  padding: 7px 14px; margin-bottom: 7px;
  box-shadow: 0 3px 0 rgba(0,0,0,.2);
}
.review-name { font-weight: 800; font-size: 13px; }
.review-comment { font-size: 12px; color: #6b5c45; flex: 1; text-align: left; margin-left: 12px; }
.review-score { font-size: 26px; font-weight: 900; color: var(--accent); width: 46px; text-align: right; font-variant-numeric: tabular-nums; }
.review-total {
  margin-top: 8px; font-size: 20px; font-weight: 900;
}
.review-total .big { font-size: 40px; color: var(--accent); }
.hall-banner {
  margin-top: 8px; padding: 8px; border: 3px solid var(--ink); border-radius: 5px;
  background: linear-gradient(90deg, #ffdf7e, #ffc44d, #ffdf7e);
  font-weight: 900; font-size: 17px; letter-spacing: 2px;
  animation: hallGlow 1s ease-in-out infinite alternate;
}
@keyframes hallGlow { from { box-shadow: 0 0 6px #ffc44d; } to { box-shadow: 0 0 22px #ffb520; } }

.fit-great { color: var(--good); font-weight: 900; }
.fit-bad { color: var(--bad); font-weight: 900; }
.fit-normal { color: #6b5c45; font-weight: 700; }

.dex-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; }
.dex-item {
  border: 2px solid var(--ink); border-radius: 4px; background: #fff;
  padding: 5px 9px; font-size: 12px; font-weight: 700;
  display: flex; justify-content: space-between;
}
.dex-item.unknown { background: #d8ccb4; color: #8a7a5e; }

.history-item {
  border: 3px solid var(--ink); border-radius: 5px; background: #fff;
  padding: 7px 12px; margin-bottom: 7px; font-size: 13px;
  box-shadow: 0 3px 0 rgba(0,0,0,.18);
}
.history-item .hi-top { display: flex; justify-content: space-between; font-weight: 900; font-size: 14px; }
.history-item .hi-sub { color: #6b5c45; font-size: 12px; margin-top: 2px; display: flex; justify-content: space-between; flex-wrap: wrap; }

.achv-item {
  display: flex; gap: 10px; align-items: center;
  border: 2px solid var(--ink); border-radius: 5px; background: #fff;
  padding: 6px 12px; margin-bottom: 6px; font-size: 13px;
}
.achv-item.locked { background: #d8ccb4; opacity: .75; }
.achv-item .ai-icon { font-size: 22px; }
.achv-item .ai-name { font-weight: 900; }
.achv-item .ai-desc { color: #6b5c45; font-size: 12px; }

.help-section { margin-bottom: 12px; }
.help-section h3 { font-size: 15px; margin-bottom: 4px; color: var(--accent); letter-spacing: 1px; }
.help-section p, .help-section li { font-size: 13px; color: #4a3d2e; }
.help-section ul { padding-left: 20px; }

.award-stage {
  text-align: center; padding: 12px 0;
}
.award-trophy { font-size: 64px; animation: trophySpin 2.4s ease-in-out infinite; display: inline-block; }
@keyframes trophySpin { 0%,100% { transform: rotate(-8deg) scale(1); } 50% { transform: rotate(8deg) scale(1.12); } }
.award-line { font-size: 15px; margin: 6px 0; }
.award-winner { font-size: 22px; font-weight: 900; color: var(--accent); }

.eval-grade { font-size: 84px; font-weight: 900; text-align: center; color: var(--gold); text-shadow: 4px 4px 0 var(--ink); }

.center { text-align: center; }
.mt8 { margin-top: 8px; }
.small-note { font-size: 12px; color: #8a7a5e; }
.warn-text { color: var(--bad); font-weight: 800; }

/* ============ Toast ============ */
#toast-root {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none;
}
.toast {
  background: var(--paper); border: 3px solid var(--ink); border-radius: 5px;
  padding: 8px 20px; font-weight: 800; font-size: 14px;
  box-shadow: 0 4px 0 rgba(0,0,0,.4);
  animation: toastIn .25s cubic-bezier(.34,1.56,.64,1);
}
.toast.out { animation: toastOut .3s ease-in forwards; }
@keyframes toastIn { from { transform: translateY(-30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes toastOut { to { transform: translateY(-24px); opacity: 0; } }
.toast-good { background: #d8f2df; }
.toast-bad { background: #fbd9d7; }
.toast-gold { background: #ffe9ad; }

/* ============ レスポンシブ ============ */
@media (max-width: 980px) {
  #game-layout { flex-direction: column; overflow-y: auto; }
  #right-col { width: 100%; }
  #office-frame { min-height: 300px; }
  body { overflow: auto; }
  #screen-game { height: auto; min-height: 100vh; }
  .title-logo-main { font-size: 44px; letter-spacing: 5px; }
  .abtn { min-width: 66px; padding: 5px 6px; }
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #d8ccb4; }
::-webkit-scrollbar-thumb { background: #6b5c45; border: 2px solid #d8ccb4; border-radius: 5px; }

/* ---------- KanaWorks_AI クレジット ---------- */
.kw-credit {
  display: inline-flex; align-items: center; gap: 9px;
  margin-top: 20px; padding: 6px 14px 6px 8px;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: 4px;
  box-shadow: 0 3px 0 var(--ink);
  text-decoration: none;
  color: var(--ink); font-size: 12.5px; font-weight: 700;
  transition: transform .12s ease, box-shadow .12s ease;
}
.kw-credit img { width: 26px; height: 26px; display: block; image-rendering: pixelated; }
.kw-credit b { color: var(--accent); }
.kw-credit:hover {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--ink);
}
