body{
     margin:0;
     background:#d8c9a3;
    font-family: Georgia, serif;
}

.page{
  display:grid;
  grid-template-columns: 1fr 1.2fr 1fr;
  height:100vh;
  border:4px solid #222;
}

.recipe-search {
  position: fixed;
  top: 12px;
  right: 18px;
  z-index: 100;
}

.search-btn {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 8px;
  background: #5a4632;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  cursor: pointer;
}

.search-btn:hover,
.search-close:hover {
  background: #704830;
}

.search-popup {
  position: absolute;
  top: 50px;
  right: 0;
  width: min(380px, calc(100vw - 24px));
  max-height: 420px;
  padding: 12px;
  box-sizing: border-box;
  border: 3px solid #5a4632;
  background: #efe1b6;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.3);
  display: none;
  flex-direction: column;
}

.search-popup[aria-hidden="false"] {
  display: flex;
}

.search-header {
  display: flex;
  gap: 8px;
}

.search-input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 2px solid #5a4632;
  border-radius: 6px;
  font: inherit;
}

.search-close {
  width: 36px;
  border: 0;
  border-radius: 6px;
  padding: 6px;
  background: #5a4632;
  color: #fff;
  cursor: pointer;
}

.search-results {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
  max-height: 320px;
}

.search-results li {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(90, 70, 50, 0.12);
  color: #3a2b1a;
  cursor: pointer;
  font-size: 15px;
}

.search-results li:hover,
.search-results li:focus-visible {
  background: rgba(90, 70, 50, 0.1);
  outline: none;
}

/* LEFT */
.left{
  border-right:3px solid #222;
  padding:10px;
}

.trade-title{
  text-align:center;
  margin-bottom:10px;
  font-size: 32px;
  font-weight: bold;
}

.trade-box{
  border:4px solid #222;
  padding:10px;
  background:#e5d6b0;
}

.trade-box img{
  width:100%;
}

.tips-title{
  margin-top:20px;
  text-align:center;
  font-size: 32px;
  font-weight: bold;
}

/* CENTER */
.center{
  text-align:center;
  padding:10px;
}

.title{
     border:4px solid #222;
    display: block;
    text-align: center;
    padding:10px 30px;
     background:#e5d6b0;
}

.sub{
  margin:10px;
}
/* container của L2 - Tesuchi */
.sub{
  display: inline-flex;
  align-items: center;
  gap: 8px;

  margin: 10px auto;
}

/* L2 badge */
.layer {
  /*width: 50px;*/
  height: auto;
  border: none;                /* remove black box border */
  display: grid;
  gap: 4px;              
  align-items: center;

  grid-auto-flow: column;        
  grid-auto-columns: max-content;

  background-color: transparent;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;    /* scale badge image to container */
  image-rendering: pixelated;  /* pixelated display */
  image-rendering: crisp-edges;

  color: transparent !important;
  text-indent: -9999px;     /* hide any text */ 
  /*overflow: hidden;*/
  white-space: nowrap;
  height: 30px;
  background: none;

}

.layer .badge {
  width: 32px;        /* same as the slot box */
  height: 32px;       /* same as the slot box */

  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;

  image-rendering: pixelated;
  image-rendering: crisp-edges;

  flex-shrink: 0; 
}

/* phần - Tesuchi */
.mob{
  font-size: 22px;
  font-weight: bold;
  color: #000;
}

/*.layer{
  background:#2d8cff;
  padding:5px 10px;
  border:4px solid #000;
}*/

.mob{
  background:#7bbf2a;
  padding:5px 10px;
  border:4px solid #000;
}

.item-image{
  border:4px solid #000;
  width:250px;
  height:250px;
  margin:10px auto;
  background:#d8c9a3;
}

.item-image img{
  width:100%;
  height:100%;
  object-fit:contain;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.desc{
  border:4px solid #000;
  width:250px;
  margin:10px auto;
  padding:10px;
  background:#e5d6b0;
}

.rarity{
  text-align:left;
}

/* RIGHT */
.right{
  border-left:4px solid #222;
  padding:10px;

  display: flex;
  flex-direction: column;
}

/* container scroll */
.recipes-container{
  overflow-y: auto;
  max-height: 80vh;
  padding-right: 5px;
}

/* scrollbar đẹp hơn (optional) */
.recipes-container::-webkit-scrollbar{
  width: 8px;
}

.recipes-container::-webkit-scrollbar-thumb{
  background: #888;
}

.recipes-title{
  text-align:center;
  font-size: 32px;
  font-weight: bold;
}

.recipe{
  display:flex;
  align-items:center;
  gap:20px; 
  margin:30px 0;
}

.grid{
width: 150px;
  height: 150px;
  left: 82px; 
  top: 0px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  /*background-color: #cfcfcf;*/

  /*border: 4px solid #5a4632;  
  box-shadow: 
    inset 0 0 0 3px #9e9e9e,    
    inset 0 0 0 6px #dcdcdc;    */

  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  /*background:
    linear-gradient(#999 2px, transparent 2px),
    linear-gradient(90deg,#999 2px, transparent 2px);
  background-size:50px 50px;
  background-color:#ccc;*/
  position:relative;
}

/*.grid div:hover{
  background: #dcdcdc;
}*/
.output{
    width: 50px;
    height: 50px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    
    left: 160px; 
    top: 3px;
    /*background-color: #cfcfcf;*/

    /*border: 4px solid #5a4632;  */
    /*box-shadow: 
      inset 0 0 0 3px #9e9e9e,    
      inset 0 0 0 6px #dcdcdc;    */

    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr); 
}

.output::after{
  content: "";
  inset: 0;

  background: url("output-frame.png") no-repeat center;
  background-size: 100% 100%;

  pointer-events: none;
  z-index: 2;
}

/* PAGINATION */
.nav{
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  background: #d8c9a3;
  border-top: 4px solid #222;
  padding: 8px 20px;
  z-index: 50;
}

#prevBtn, #nextBtn{
  width: 44px;
  height: 44px;
  border: none;
  background: #5a4632;
  color: #fff;
  font-size: 20px;
  cursor: pointer;
}

#prevBtn:disabled, #nextBtn:disabled{
  opacity: 0.5;
  cursor: not-allowed;
}

.page-indicator {
  width: 120px;
  text-align: center;
  background: transparent;
  border: 2px solid #222;
  color: #222;
  font-family: Georgia, serif;
  font-size: 14px;
  font-weight: bold;
  padding: 4px 8px;
}

.page-indicator:focus {
  text-decoration: underline;
}

/* === Tip container === */
.tip{
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin-bottom: 30px;
}

/* === Avatar image === */
.tip-avatar{
  width: 120px;
  height: 120px;
  object-fit: cover;
  flex-shrink: 0;
}

/* === Speech bubble === */
.tip-box{
  position: relative;
  background: #fff;
  color: #000;
  padding: 6px 10px;
  border-radius: 8px;
  border: 2px solid #000;
  font-size: 16px;
  line-height: 1.2;
  max-width: 100%;
  box-sizing: border-box;
  margin-left: 15px;
}

/* tail */
.tip-box::before{
  content: "";
  position: absolute;
  left: -10px;
  top: 10px;
  border-width: 6px 10px 6px 0;
  border-style: solid;
  border-color: transparent #000 transparent transparent;
}

.tip-box::after{
  content: "";
  position: absolute;
  left: -7px;
  top: 11px;
  border-width: 5px 9px 5px 0;
  border-style: solid;
  border-color: transparent #fff transparent transparent;
}
.panel{
  background: var(--bg-panel);
  border: 4px solid var(--border-main);
  padding: 10px;
  box-shadow: inset 0 0 0 2px #cbb893;
}
/* đảm bảo recipe làm mốc */
.recipe{
  position: relative;
  width: 500px; 
  height: 245px;
}

/* overlay PNG */
.recipe::after{
  content: "";
  position: absolute;
  inset: 0;

  image-rendering: pixelated;
  image-rendering: crisp-edges;
  
  background: url("./assets/crafting_ui.png") no-repeat center;
  background-size: 100% 100%;

  pointer-events: none;
  z-index: -1;
}

/* cho phép hover */
.grid div, .output{
  position: relative;
  transition: transform 0.15s ease;
}

/* zoom */
.grid div:hover,
.output:hover{
  transform: scale(1.3);
  z-index: 50;
}

/* tooltip */
.grid div:hover::after{
  content: attr(data-name);

  position: absolute;
  bottom: 110%;
  left: 50%;
  transform: translateX(-50%);

  background: #111;
  color: #fff;

  padding: 6px 10px;
  border: 2px solid #5a4632;

  font-family: 'Press Start 2P', monospace;
  font-size: 12px;

  white-space: nowrap;
  z-index: 999;
}
.output:hover::after{
  content: attr(data-name);

  position: relative;
  top:  -40px;

  left: 35%;
  transform: translateX(-50%);

  background: rgba(0,0,0,0.95);
  color: #fff;

  padding: 8px 11px;
  border: 2px solid #5a4632;

  font-family: 'Press Start 2P', monospace;
  font-size: 12px;

  white-space: nowrap;

  display: inline-block;
  width: max-content;

  z-index: 999;
}

/* ===== TRADE (Villager style) ===== */

.trade-container{
  display:flex;
  flex-direction:column;
  gap:20px;
}

/* 1 trade row */
.trade-recipe{
  position: relative;
  width: 400px;
  height: 190px;
}

/* overlay PNG */
.trade-recipe::after{
  content:"";
  position:absolute;
  inset:0;

  background:url("./assets/trading_ui.png") no-repeat center;
  background-size:100% 100%;

  image-rendering: pixelated;
  pointer-events:none;
  z-index:0;
}

/* slot chung */
.trade-slot{
  position:absolute;
  width:40px;
  height:40px;

  background-size:contain;
  background-repeat:no-repeat;

  image-rendering:pixelated;
  z-index:2;
}

/* vị trí 2 input */
.trade-in1{ left:85px; top:85px; }
.trade-in2{ left:145px; top:85px; }

/* output */
.trade-out{ left:275px; top:85px; }

/* hover giống crafting */
.trade-slot:hover{
  transform: scale(1.3);
  z-index:50;
}

/* tooltip */
.trade-slot:hover::after{
  content: attr(data-name);

  position:absolute;
  top:-35px;
  left:50%;
  transform:translateX(-50%);

  background:#111;
  color:#fff;

  padding:6px 10px;
  border:2px solid #5a4632;

  font-family:'Press Start 2P', monospace;
  font-size:12px;

  white-space:nowrap;
  z-index:999;
}

#mark{
  position: fixed;
  bottom: -115px;
  right: -70px;
  scale: 0.42;
}

#go_back {
  position: fixed;
  scale: 0.5;
  bottom: 30px;
  right: 35px;
  z-index: 1000;
  transition: transform 0.2s ease;
}

#go_back img {
  width: 145px;
  vertical-align: middle;

}