@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@400;700&family=Noto+Serif+JP:wght@400;700&display=swap');

/* ===== CSS VARIABLES ===== */
:root {
  --bg:      #110d06;
  --bg2:     #1e1509;
  --bg3:     #16110a;
  --paper:   #c8a870;
  --paper2:  #a07840;
  --gold:    #c9a227;
  --gold2:   #f0c040;
  --iron:    #8a9aaa;
  --coal:    #555;
  --beer:    #c47d2a;
  --red:     #8b1a1a;
  --border:  #6a4c1a;
  --text:    #e8dcc8;
  --sidebar-w: 200px;
}

/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  background-image:
    repeating-linear-gradient(45deg,  rgba(255,255,255,.02) 0, rgba(255,255,255,.02) 1px, transparent 1px, transparent 12px),
    repeating-linear-gradient(-45deg, rgba(255,255,255,.02) 0, rgba(255,255,255,.02) 1px, transparent 1px, transparent 12px);
  color: var(--text);
  font-family: 'Noto Serif JP', serif;
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
}

a { color: var(--gold2); text-decoration: none; }
a:hover { color: var(--paper); }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ===== APP HEADER (shared) ===== */
.app-header {
  background: var(--bg2);
  border-bottom: 2px solid var(--border);
  padding: 10px 18px;
  display: flex;
  align-items: center;
  gap: 14px;
}
.app-logo {
  font-family: 'Cinzel', serif;
  font-size: .88rem;
  color: var(--gold2);
  letter-spacing: 2px;
  white-space: nowrap;
}
.app-logo span { color: var(--paper2); font-size: .68rem; display: block; letter-spacing: 1px; }
.back-link {
  font-size: .72rem;
  color: var(--paper2);
  display: flex;
  align-items: center;
  gap: 4px;
  transition: color .15s;
}
.back-link:hover { color: var(--gold2); }

/* ===== GAME PAGE HEADER ===== */
.game-header {
  position: relative;
  overflow: hidden;
  border-bottom: 3px solid var(--gold);
  min-height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.game-header-bg {
  position: absolute; inset: 0;
  background-size: cover;
  background-position: center;
  filter: brightness(0.22) saturate(0.6);
}
.game-header-content {
  position: relative; z-index: 1;
  text-align: center;
  padding: 16px 60px;
  width: 100%;
}
.header-gear {
  position: absolute; top: 50%; transform: translateY(-50%);
  font-size: 1.8rem; color: var(--gold); opacity: .7;
  animation: spin 12s linear infinite;
  user-select: none;
}
.header-gear.left  { left: 14px; }
.header-gear.right { right: 14px; animation-direction: reverse; }
@keyframes spin { to { transform: translateY(-50%) rotate(360deg); } }

.game-header h1 {
  font-family: 'Cinzel', serif;
  font-size: clamp(.95rem, 3.5vw, 1.5rem);
  color: var(--gold2);
  letter-spacing: 3px;
  text-shadow: 0 0 20px rgba(201,162,39,.6);
}
.game-header .subtitle {
  font-size: .68rem;
  color: var(--paper2);
  font-style: italic;
  margin-top: 3px;
}
.bgg-badge {
  display: inline-block;
  margin-top: 6px;
  padding: 3px 12px;
  border-radius: 12px;
  background: rgba(201,162,39,.15);
  border: 1px solid var(--gold);
  font-size: .62rem;
  color: var(--gold2);
  font-family: 'Cinzel', serif;
  letter-spacing: 1px;
}

/* ===== GAME PAGE LAYOUT ===== */
.game-layout { display: flex; min-height: calc(100vh - 150px); }

/* Sidebar (desktop) */
.game-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 14px 0;
}
.sidebar-title {
  font-family: 'Cinzel', serif;
  font-size: .6rem;
  color: var(--paper2);
  letter-spacing: 2px;
  padding: 0 12px 8px;
  border-bottom: 1px solid rgba(106,76,26,.3);
  margin-bottom: 6px;
  text-transform: uppercase;
}
.sidebar-link {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  font-size: .76rem;
  color: var(--paper2);
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all .15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-link:hover { color: var(--text); background: rgba(255,255,255,.03); }
.sidebar-link.active {
  color: var(--gold2);
  border-left-color: var(--gold);
  background: rgba(201,162,39,.07);
}
.sidebar-link .sec-icon { font-size: .82rem; flex-shrink: 0; }

/* Mobile tab nav */
.mobile-nav {
  display: none;
  background: var(--bg2);
  border-bottom: 2px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  position: sticky;
  top: 0;
  z-index: 100;
}
.mobile-nav::-webkit-scrollbar { display: none; }
.mob-nav-btn {
  flex: none;
  padding: 10px 13px;
  background: none;
  border: none;
  color: var(--paper2);
  font-family: 'Noto Serif JP', serif;
  font-size: .76rem;
  cursor: pointer;
  border-bottom: 3px solid transparent;
  white-space: nowrap;
  transition: all .2s;
}
.mob-nav-btn.active { color: var(--gold2); border-bottom-color: var(--gold); background: rgba(201,162,39,.08); }
.mob-nav-btn:hover:not(.active) { color: var(--paper); background: rgba(255,255,255,.04); }

/* Game content */
.game-content {
  flex: 1;
  min-width: 0;
  padding: 14px 14px 40px;
  max-width: 700px;
}

/* Section */
.game-section { margin-bottom: 28px; scroll-margin-top: 16px; }
.game-section.hidden { display: none; }

.sec-header { text-align: center; padding: 12px 0 8px; margin-bottom: 10px; }
.sec-header h2 {
  font-family: 'Cinzel', serif;
  font-size: 1rem;
  color: var(--gold2);
  letter-spacing: 3px;
}
.sec-divider {
  display: flex; align-items: center; gap: 8px; margin-top: 6px;
}
.sec-divider::before, .sec-divider::after {
  content: ''; flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}
.sec-divider span { color: var(--gold); font-size: .75rem; }

/* ===== CARD BLOCK ===== */
.block-card {
  background: linear-gradient(135deg, rgba(200,168,112,.1) 0%, rgba(200,168,112,.04) 100%);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 13px;
  margin-bottom: 10px;
  position: relative;
}
.block-card::before {
  content: ''; position: absolute; inset: 4px;
  border: 1px solid rgba(106,76,26,.2); border-radius: 2px;
  pointer-events: none;
}
.card-title {
  font-family: 'Cinzel', serif;
  font-size: .84rem;
  color: var(--gold);
  display: flex; align-items: center; gap: 7px;
  padding-bottom: 7px;
  border-bottom: 1px solid rgba(106,76,26,.4);
  margin-bottom: 9px;
}

/* ===== LIST BLOCK ===== */
ul.block-list { list-style: none; }
ul.block-list li {
  font-size: .73rem; color: var(--text); line-height: 1.65;
  padding: 2px 0 2px 13px; position: relative;
}
ul.block-list li::before {
  content: '▸'; position: absolute; left: 0;
  color: var(--border); font-size: .62rem; top: 5px;
}

/* ===== STEPS BLOCK ===== */
.block-step { display: flex; gap: 9px; margin-bottom: 7px; align-items: flex-start; }
.step-num {
  width: 21px; height: 21px; border-radius: 50%;
  background: rgba(201,162,39,.18); border: 1px solid var(--gold);
  color: var(--gold2); font-family: 'Cinzel', serif; font-size: .68rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 1px;
}
.step-title { font-size: .78rem; color: var(--gold); font-weight: 700; margin-bottom: 2px; }
.step-desc  { font-size: .71rem; color: var(--text); line-height: 1.55; }

/* ===== STATS BLOCK ===== */
.block-stats {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 7px; margin-bottom: 10px;
}
.stat-item {
  background: rgba(200,168,112,.07);
  border: 1px solid rgba(106,76,26,.35);
  border-radius: 4px; padding: 7px 4px; text-align: center;
}
.stat-value { font-family: 'Cinzel', serif; font-size: .98rem; color: var(--gold2); }
.stat-label { font-size: .58rem; color: var(--paper2); margin-top: 2px; }

/* ===== COMPONENTS BLOCK ===== */
.block-components { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 12px; }
.comp-item { font-size: .71rem; color: var(--text); }
.comp-count { color: var(--gold); font-weight: 700; margin-right: 4px; }

/* ===== GALLERY BLOCK ===== */
.block-gallery {
  display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px;
  scrollbar-width: thin; scrollbar-color: var(--border) var(--bg);
  padding-bottom: 4px;
}
.block-gallery::-webkit-scrollbar { height: 4px; }
.block-gallery::-webkit-scrollbar-track { background: var(--bg); }
.block-gallery::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.block-gallery img {
  height: 88px; width: auto; flex-shrink: 0;
  border-radius: 3px; border: 1px solid var(--border);
  filter: brightness(0.85) saturate(0.8);
  cursor: pointer; transition: filter .2s, transform .2s;
}
.block-gallery img:hover { filter: brightness(1) saturate(1); transform: scale(1.03); }

/* ===== PHOTO BLOCK ===== */
.block-photo {
  width: 100%; border-radius: 4px; overflow: hidden;
  margin-bottom: 10px; position: relative; border: 1px solid var(--border);
}
.block-photo img { width: 100%; display: block; filter: brightness(0.9) saturate(0.85); cursor: pointer; }
.photo-caption {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,.8));
  padding: 14px 10px 7px;
  font-size: .6rem; color: var(--paper2); font-style: italic; text-align: right;
}

/* ===== PHOTO PAIR BLOCK ===== */
.block-photo-pair { display: flex; gap: 8px; margin-bottom: 10px; }
.pair-item { flex: 1; border-radius: 4px; border: 1px solid var(--border); overflow: hidden; }
.pair-item img { width: 100%; display: block; filter: brightness(0.88) saturate(0.82); cursor: pointer; }
.pair-caption {
  font-size: .6rem; color: var(--paper2); font-style: italic;
  text-align: center; margin: 4px 0 6px;
}

/* ===== ACTION GRID BLOCK ===== */
.block-action-grid {
  display: grid; grid-template-columns: repeat(2, 1fr);
  gap: 8px; margin-bottom: 12px;
}
.action-card {
  background: rgba(200,168,112,.06);
  border: 1px solid rgba(106,76,26,.5);
  border-radius: 4px; padding: 10px;
}
.action-icon { font-size: 1.3rem; display: block; margin-bottom: 4px; }
.action-name { font-family: 'Cinzel', serif; font-size: .76rem; color: var(--gold); margin-bottom: 4px; }
.action-desc { font-size: .67rem; color: var(--text); line-height: 1.55; margin-bottom: 5px; }
.action-cost {
  font-size: .6rem; color: var(--paper2);
  background: rgba(0,0,0,.2); border-radius: 2px;
  padding: 2px 6px; display: inline-block;
}

/* ===== BUILDING CARD BLOCK ===== */
.block-building {
  background: rgba(200,168,112,.06);
  border: 1px solid rgba(106,76,26,.4);
  border-radius: 4px; padding: 12px; margin-bottom: 10px; overflow: hidden;
}
.building-header { display: flex; align-items: center; gap: 9px; margin-bottom: 7px; }
.building-icon {
  width: 33px; height: 33px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.05rem; flex-shrink: 0;
}
.building-icon.iron { background: rgba(138,154,170,.2); border: 1px solid var(--iron); }
.building-icon.coal { background: rgba(68,68,68,.35);   border: 1px solid #777; }
.building-icon.beer { background: rgba(196,125,42,.2);  border: 1px solid var(--beer); }
.building-icon.cons { background: rgba(139,26,26,.2);   border: 1px solid #a03030; }
.building-name     { font-family: 'Cinzel', serif; font-size: .83rem; color: var(--gold); }
.building-en-name  { font-size: .63rem; color: var(--paper2); margin-top: 1px; }
.building-desc { font-size: .71rem; color: var(--text); line-height: 1.6; margin-bottom: 7px; }
.building-tags { display: flex; flex-wrap: wrap; gap: 4px; }
.building-photo-wrap {
  float: right; width: 42%; margin: 0 0 8px 11px;
  border-radius: 3px; border: 1px solid var(--border); overflow: hidden;
}
.building-photo-wrap img { width: 100%; display: block; filter: brightness(0.88) saturate(0.8); cursor: pointer; }
.building-photo-cap {
  font-size: .57rem; color: var(--paper2); font-style: italic;
  padding: 3px 6px; background: rgba(0,0,0,.4);
}
.clearfix::after { content: ''; display: block; clear: both; }

/* ===== RESOURCE BOX BLOCK ===== */
.block-resource {
  border-radius: 4px; padding: 11px 13px;
  margin-bottom: 10px; border-left: 3px solid;
}
.block-resource.rc-c { background: rgba(68,68,68,.15);    border-color: #888; }
.block-resource.rc-i { background: rgba(138,154,170,.12); border-color: var(--iron); }
.block-resource.rc-b { background: rgba(196,125,42,.12);  border-color: var(--beer); }
.resource-title { font-family: 'Cinzel', serif; font-size: .8rem; color: var(--gold); margin-bottom: 7px; }

/* ===== ERA COMPARE BLOCK ===== */
.block-era-compare { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.era-col { border-radius: 4px; padding: 10px 11px; border: 1px solid rgba(106,76,26,.4); }
.era-col.canal { background: rgba(30,90,150,.1);  border-color: #3a6090; }
.era-col.rail  { background: rgba(80,30,30,.15);  border-color: #703030; }
.era-title { font-family: 'Cinzel', serif; font-size: .76rem; color: var(--gold2); margin-bottom: 7px; text-align: center; }

/* ===== TABLE BLOCK ===== */
.block-table { width: 100%; border-collapse: collapse; margin-bottom: 10px; font-size: .71rem; }
.block-table th {
  background: rgba(106,76,26,.25); color: var(--gold);
  padding: 6px 9px; text-align: left;
  font-family: 'Cinzel', serif; font-size: .67rem; font-weight: normal;
}
.block-table td { padding: 6px 9px; border-bottom: 1px solid rgba(106,76,26,.2); color: var(--text); vertical-align: top; }
.block-table tr:last-child td { border-bottom: none; }
.block-table tr:nth-child(even) td { background: rgba(255,255,255,.025); }

/* ===== ACCORDION BLOCK ===== */
.acc-item { border-bottom: 1px solid rgba(106,76,26,.25); }
.acc-q {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 0; cursor: pointer; user-select: none;
}
.acc-q:hover .acc-qt { color: var(--text); }
.acc-qm {
  width: 19px; height: 19px; border-radius: 50%;
  background: rgba(201,162,39,.2); border: 1px solid var(--gold);
  color: var(--gold2); font-family: 'Cinzel', serif; font-size: .62rem;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.acc-qt { font-size: .74rem; color: var(--paper2); flex: 1; line-height: 1.4; }
.acc-arrow { color: var(--border); font-size: .63rem; transition: transform .2s; }
.acc-item.open .acc-arrow { transform: rotate(90deg); color: var(--gold); }
.acc-a { display: none; padding: 3px 0 11px 27px; }
.acc-item.open .acc-a { display: block; }
.acc-a p { font-size: .71rem; color: var(--text); line-height: 1.7; }

/* ===== TEXT & DIVIDER ===== */
.block-text { font-size: .73rem; color: var(--text); line-height: 1.7; margin-bottom: 8px; }
.block-divider { text-align: center; margin: 11px 0; color: var(--border); font-size: .74rem; letter-spacing: 4px; }
.block-credits { font-size: .61rem; color: var(--paper2); text-align: center; font-style: italic; margin: 5px 0 9px; }

/* ===== STRATEGY TIPS ===== */
.tip-item { display: flex; gap: 9px; margin-bottom: 8px; align-items: flex-start; }
.tip-num {
  width: 19px; height: 19px; border-radius: 50%;
  background: rgba(201,162,39,.15); border: 1px solid rgba(201,162,39,.4);
  color: var(--gold); font-size: .63rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 2px; font-family: 'Cinzel', serif;
}
.tip-body { font-size: .72rem; color: var(--text); line-height: 1.6; }
.tip-title { color: var(--gold); font-weight: 700; margin-bottom: 2px; font-size: .74rem; }

/* ===== UTILITY: INLINE COLORS ===== */
.g  { color: var(--gold2); font-weight: 700; }
.co { color: #aaa; }
.ir { color: var(--iron); }
.be { color: var(--beer); }

.badge { display: inline-block; padding: 1px 7px; border-radius: 10px; font-size: .61rem; font-family: 'Cinzel', serif; letter-spacing: .5px; }
.b-c { background: rgba(30,90,150,.2);  border: 1px solid #3a6090; color: #80b0e0; }
.b-r { background: rgba(80,30,30,.25);  border: 1px solid #803030; color: #e08080; }

.tag { display: inline-block; padding: 2px 7px; border-radius: 10px; font-size: .6rem; margin: 0 2px 2px 0; }
.tc { background: rgba(68,68,68,.3);    border: 1px solid #888;         color: #ccc; }
.ti { background: rgba(138,154,170,.2); border: 1px solid var(--iron);  color: var(--iron); }
.tb { background: rgba(196,125,42,.2);  border: 1px solid var(--beer);  color: var(--beer); }
.tg { background: rgba(201,162,39,.15); border: 1px solid var(--gold);  color: var(--gold2); }
.tr { background: rgba(139,26,26,.2);   border: 1px solid #a03030;      color: #e06060; }

/* ===== MODAL ===== */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,.92); z-index: 1000;
  align-items: center; justify-content: center; padding: 20px;
}
.modal-overlay.open { display: flex; }
.modal-overlay img { max-width: 100%; max-height: 90vh; border-radius: 4px; border: 2px solid var(--gold); }
.modal-close {
  position: absolute; top: 16px; right: 16px;
  background: rgba(201,162,39,.2); border: 1px solid var(--gold);
  color: var(--gold2); width: 36px; height: 36px;
  border-radius: 50%; font-size: 1.2rem; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}

/* ===== INDEX PAGE ===== */
.index-hero {
  text-align: center; padding: 28px 20px 20px;
  border-bottom: 1px solid rgba(106,76,26,.3);
}
.index-hero h2 {
  font-family: 'Cinzel', serif;
  font-size: clamp(1rem, 4vw, 1.7rem);
  color: var(--gold2); letter-spacing: 4px; margin-bottom: 7px;
}
.index-hero p { font-size: .76rem; color: var(--paper2); }

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px; padding: 20px 18px 40px;
  max-width: 1060px; margin: 0 auto;
}
.game-card {
  background: linear-gradient(135deg, rgba(200,168,112,.1), rgba(200,168,112,.04));
  border: 1px solid var(--border); border-radius: 5px;
  overflow: hidden; cursor: pointer;
  transition: border-color .2s, transform .15s, box-shadow .2s;
  display: block; color: var(--text);
}
.game-card:hover {
  border-color: var(--gold); transform: translateY(-2px);
  box-shadow: 0 6px 22px rgba(0,0,0,.5); color: var(--text);
}
.game-card-img {
  width: 100%; height: 130px; object-fit: cover;
  filter: brightness(0.78) saturate(0.75); display: block; transition: filter .2s;
}
.game-card:hover .game-card-img { filter: brightness(0.9) saturate(0.9); }
.game-card-body { padding: 11px 13px 13px; }
.game-card-title { font-family: 'Cinzel', serif; font-size: .88rem; color: var(--gold2); margin-bottom: 2px; }
.game-card-en    { font-size: .63rem; color: var(--paper2); font-style: italic; margin-bottom: 7px; }
.game-card-desc  { font-size: .69rem; color: var(--text); line-height: 1.55; margin-bottom: 9px; }
.game-card-meta  { display: flex; flex-wrap: wrap; gap: 4px; }
.meta-chip {
  font-size: .59rem; padding: 2px 7px; border-radius: 10px;
  background: rgba(106,76,26,.22); border: 1px solid rgba(106,76,26,.4); color: var(--paper2);
}
.meta-chip.rank { background: rgba(201,162,39,.12); border-color: var(--gold); color: var(--gold2); }

.games-loading, .games-empty {
  text-align: center; padding: 60px 20px; color: var(--paper2); font-size: .8rem;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 767px) {
  .game-sidebar  { display: none; }
  .mobile-nav    { display: flex; }
  .game-content  { padding: 11px 11px 32px; max-width: 100%; }
  .block-stats   { grid-template-columns: repeat(2, 1fr); }
  .block-action-grid  { grid-template-columns: 1fr; }
  .block-components   { grid-template-columns: 1fr; }
  .block-photo-pair   { flex-direction: column; }
  .building-photo-wrap { width: 46%; }
  .block-era-compare  { grid-template-columns: 1fr; }
}
@media (min-width: 768px) {
  .mobile-nav { display: none; }
  .game-sidebar { display: block; }
  .game-section.hidden { display: block !important; }
}
