:root{
  --bg: #f8f2e1;
  --panel: #fff8dc;
  --panel-2: #ffe9b4;
  --border: #8b5e3c;
  --gold: #d4af37;
  --gold-dark: #b68b22;
  --text: #352214;
  --danger: #a63b2d;
  --success: #2f6b3c;
  --muted: #6d584a;
  --shadow: 0 10px 24px rgba(74, 43, 20, 0.14);
}

*{box-sizing:border-box}
html,body{margin:0;padding:0}
body{
  background: var(--bg);
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
}

a{color:inherit}
img{max-width:100%;display:block}

.top-header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:18px;
  padding:14px 22px;
  background:var(--panel);
  border-bottom:3px solid var(--border);
  position:sticky;
  top:0;
  z-index:50;
  box-shadow: 0 4px 14px rgba(0,0,0,0.06);
}
.brand{
  display:flex;
  align-items:center;
  gap:14px;
}
.brand h1{
  margin:0;
  font-size:32px;
}
.brand img{
  width:46px;
  height:46px;
}
.header-buttons{
  display:flex;
  flex-wrap:wrap;
  gap:10px;
}
.header-btn{
  display:inline-flex;
  align-items:center;
  gap:8px;
  text-decoration:none;
  border:2px solid var(--border);
  background:var(--gold);
  color:#24160d;
  font-weight:700;
  padding:10px 14px;
  border-radius:12px;
  box-shadow: var(--shadow);
}
.header-btn:hover{
  background:var(--gold-dark);
}
.header-btn img{
  width:22px;
  height:22px;
}
.header-pseudo{
  padding:10px 14px;
  border-radius:12px;
  border:2px solid var(--border);
  background:#f3e0ab;
  font-weight:700;
}

.page-wrap{
  width:min(1400px, 96vw);
  margin:22px auto;
}

.flash{
  margin:16px auto;
  padding:14px 18px;
  border-radius:12px;
  border:2px solid var(--border);
  background:#fff3c9;
  box-shadow: var(--shadow);
}
.flash.success{border-color:#2f6b3c;background:#e8f7ea;color:#214c29}
.flash.error{border-color:#a63b2d;background:#fdecea;color:#7a2319}

.main-layout{
  display:grid;
  grid-template-columns: minmax(240px, 0.95fr) minmax(420px, 1.35fr) minmax(310px, 1fr);
  gap:18px;
  align-items:start;
}
.panel{
  background:var(--panel);
  border:3px solid var(--border);
  border-radius:18px;
  padding:20px;
  box-shadow:var(--shadow);
}
.left,.center,.right{
  min-height:calc(100vh - 150px);
}
.left{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:18px;
}
.coin-area{
  width:min(320px, 100%);
  display:flex;
  align-items:center;
  justify-content:center;
  padding-top:8px;
}
.coin-btn{
  appearance:none;
  border:none;
  background:transparent;
  cursor:pointer;
  transition:transform .08s ease, filter .2s ease;
}
.coin-btn:hover{filter:brightness(1.04)}
.coin-btn:active{transform:scale(0.96)}
.coin-btn img{
  width:min(290px, 72vw);
  height:auto;
}
.coin-btn.disabled{
  cursor:not-allowed;
  opacity:0.6;
  filter:grayscale(0.4);
}
.stat-block{
  width:100%;
  background:#fff0bc;
  border:2px solid #c79854;
  border-radius:14px;
  padding:14px 16px;
}
.stat-line{
  display:flex;
  justify-content:space-between;
  gap:12px;
  font-size:23px;
  font-weight:700;
  padding:4px 0;
}
.stat-line small{
  font-size:15px;
  color:var(--muted);
}
.notice{
  font-size:15px;
  color:var(--muted);
  text-align:center;
  line-height:1.4;
}

.section-title{
  margin:0 0 12px;
  font-size:28px;
  text-align:center;
}
.section-subtitle{
  margin:0 0 14px;
  text-align:center;
  color:var(--muted);
}
.center{
  display:flex;
  flex-direction:column;
  gap:18px;
}
.cards-grid{
  display:grid;
  gap:14px;
}
.button-upgrade,
.shop-offer,
.building-entry{
  width:100%;
  border:2px solid var(--border);
  background:#ffefc4;
  border-radius:16px;
  cursor:pointer;
  color:var(--text);
  box-shadow: var(--shadow);
}
.button-upgrade:hover,
.shop-offer:hover,
.building-entry:hover{
  background:#ffe19c;
}
.button-upgrade[disabled],
.shop-offer[disabled],
.building-entry[disabled]{
  opacity:.55;
  cursor:not-allowed;
  filter:grayscale(0.15);
}
.button-upgrade{
  display:grid;
  grid-template-columns:56px 1fr auto;
  gap:14px;
  align-items:center;
  padding:14px;
  text-align:left;
}
.button-upgrade img{
  width:52px;
  height:52px;
  object-fit:contain;
}
.item-title{
  font-size:22px;
  font-weight:700;
}
.item-desc{
  font-size:14px;
  color:var(--muted);
  margin-top:3px;
}
.item-meta{
  text-align:right;
  font-size:15px;
  font-weight:700;
  min-width:120px;
}
.shop-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit,minmax(220px,1fr));
  gap:14px;
}
.shop-offer{
  padding:16px;
  display:flex;
  flex-direction:column;
  gap:10px;
}
.shop-offer .shop-title{
  font-size:22px;
  font-weight:700;
}
.shop-offer p{
  margin:0;
  color:var(--muted);
  line-height:1.4;
}
.shop-offer .shop-footer{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  font-weight:700;
}
.shop-used{
  color:var(--danger);
  font-size:14px;
}
.right{
  display:flex;
  flex-direction:column;
  gap:12px;
  max-height:calc(100vh - 150px);
  overflow:auto;
}
.building-entry{
  display:grid;
  grid-template-columns:62px 1fr auto;
  gap:14px;
  align-items:center;
  padding:12px;
  text-align:left;
}
.building-entry img{
  width:56px;
  height:56px;
  object-fit:contain;
}
.fallback-icon{
  width:56px;
  height:56px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:30px;
  border-radius:14px;
  border:2px solid #ad8856;
  background:#f5deb0;
}
.right-top{
  display:flex;
  justify-content:space-between;
  align-items:end;
  gap:16px;
}
.small-muted{
  color:var(--muted);
  font-size:14px;
}

.actions-row{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}
.secondary-btn,
.danger-btn,
.primary-btn{
  appearance:none;
  border:2px solid var(--border);
  background:#f2ddb0;
  border-radius:12px;
  padding:11px 14px;
  font-weight:700;
  text-decoration:none;
  color:inherit;
  cursor:pointer;
  box-shadow:var(--shadow);
}
.primary-btn{background:var(--gold)}
.danger-btn{background:#efc0b8}
.secondary-btn:hover,.danger-btn:hover,.primary-btn:hover{
  filter:brightness(.97);
}

.form-card{
  width:min(580px, 94vw);
  margin:40px auto;
  background:var(--panel);
  border:3px solid var(--border);
  border-radius:18px;
  padding:28px;
  box-shadow:var(--shadow);
}
.form-card h2{
  margin:0 0 8px;
  text-align:center;
  font-size:34px;
}
.form-card p{
  color:var(--muted);
  text-align:center;
  margin:0 0 20px;
}
.form-grid{
  display:grid;
  gap:14px;
}
label{
  display:grid;
  gap:6px;
  font-weight:700;
}
input{
  font:inherit;
  border:2px solid #b99364;
  border-radius:12px;
  padding:12px 14px;
  background:#fff7de;
}
.form-footer{
  display:flex;
  justify-content:center;
  gap:10px;
  flex-wrap:wrap;
  margin-top:18px;
}
.helper-links{
  text-align:center;
  margin-top:16px;
}
.helper-links a{
  font-weight:700;
}
.table-card{
  background:var(--panel);
  border:3px solid var(--border);
  border-radius:18px;
  padding:24px;
  box-shadow:var(--shadow);
}
.ranking-table{
  width:100%;
  border-collapse:collapse;
  overflow:hidden;
}
.ranking-table th,
.ranking-table td{
  padding:14px;
  text-align:center;
  border-bottom:1px solid #d1b58b;
}
.ranking-table thead th{
  background:var(--gold);
}
.ranking-table tbody tr:nth-child(even){
  background:#fff2c9;
}
.ranking-table tbody tr:hover{
  background:#fde6aa;
}
.rank-badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:34px;
  font-weight:700;
}
.rank-badge img{
  width:34px;
  height:34px;
}
.empty-state{
  text-align:center;
  color:var(--muted);
  padding:28px 12px;
}
.info-grid{
  display:grid;
  gap:14px;
  grid-template-columns:repeat(auto-fit,minmax(220px,1fr));
  margin-bottom:22px;
}
.info-box{
  background:#fff0bc;
  border:2px solid #c79854;
  border-radius:14px;
  padding:14px;
}
.info-box strong{
  display:block;
  margin-bottom:6px;
}

@media (max-width: 1120px){
  .main-layout{
    grid-template-columns:1fr;
  }
  .left,.center,.right{
    min-height:auto;
  }
  .right{
    max-height:none;
  }
}
@media (max-width: 980px){
  .shop-grid{
    grid-template-columns:repeat(2, minmax(0, 1fr));
  }
}
@media (max-width: 640px){
  .top-header{
    padding:12px;
  }
  .brand h1{font-size:25px}
  .button-upgrade,
  .building-entry{
    grid-template-columns:50px 1fr;
  }
  .item-meta{
    grid-column:2;
    text-align:left;
    min-width:unset;
  }
  .shop-grid{
    grid-template-columns:1fr;
  }
}