@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Jersey+25&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Jersey+10&display=swap');

html, body {
  overscroll-behavior: none;
}

body {
  background-color: #cbf0f1;
  background-color: #222222;
  background-image: url("../img/az-subtle.png");
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  margin: 0;
  font-family: "Courier New", Courier, monospace;
  transform: scale(150%);
  overflow: hidden;
  flex-direction: column;
}

#camera {
  width: 480px;
  height: 320px;
  /* width: 1000px;
  height: 1000px; */
  position: relative;
  overflow: hidden;
  border-radius: 0;
  border: 8px solid #fff;
  border-bottom-width: 12px;
  /* border: 6px solid #c36460;
  outline: 6px solid #d9806b;
  box-shadow: 0px 0px 0px 10px #6e4942; */
  image-rendering: pixelated;
  user-select: none;
  -webkit-user-select: none;
}

#help-text {
  font-family: "Jersey 25", monospace, sans-serif;
  color: #fff;
}

#start-screen {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background:#7FAD71 url("../img/misc/start-screen-bg.png") repeat-x top left;
  background-size: auto 100%;
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 100;
  text-align: center;
  font-family: "Jersey 10", monospace, sans-serif;
  image-rendering: pixelated;
  animation: scrollBackground 100s linear infinite;
}

@keyframes scrollBackground {
  from {
    background-position: 0 0;
  }
  to {
    background-position: -1000px 0; /* Ändra till ett positivt värde (t.ex. 1000px) om du vill skrolla åt andra hållet */
  }
}

#game-title {
  animation: float 3s ease-in-out infinite;
}

#game-title img {
  width: 75%;
}

/* #game-title {
  color: #f4f8e4;
  margin-bottom: 20px;
  font-size: 64px;
  text-transform: uppercase;
  letter-spacing: 2px;
  text-shadow:
    3px 3px 0 #6b8dd2,
    -3px -3px 0 #6b8dd2,
    3px -3px 0 #6b8dd2,
    -3px 3px 0 #476298,
    0px 6px 0 #476298;
  animation: float 3s ease-in-out infinite;
}

#game-title::before,
#game-title::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
}

#game-title::before {
  clip-path: inset(0 0 53% 0);
  transform: translateY(-2px);
}

#game-title::after {
  clip-path: inset(47% 0 0 0);
  transform: translateY(2px);
  color: #82e5c3;
} */

#start-screen p {
  font-size: 24px;
  line-height: 1.3;
  margin-bottom: 40px;
  color: #f4f8e4;
  text-shadow:
    2px 2px 0 #6b8dd2,
    -1px -1px 0 #6b8dd2,
    1px -1px 0 #476298,
    -1px 1px 0 #476298;
}

#start-game {
  font-family: "Jersey 10", monospace, sans-serif;
  color: #f4f8e4;
  background-color: transparent;
  border: 0;
  font-size: 20px;
  cursor: pointer;
  outline: none;
  text-shadow: 2px 2px 0 #476298;
}

/* --- Animations --- */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

#ui-bar {
  position: absolute;
  top: 10px;
  right: 10px;
  background-color: #f1b093;
  color: #60433f;
  border: 2px solid #c36460;
  outline: 3px solid #d9806b;
  box-shadow: 0px 0px 0px 4px #6e4942;
  image-rendering: pixelated;
  padding: 5px 10px;
  z-index: 30;
  font-family: "Jersey 10",  monospace, sans-serif;
}

#idea-count {
  color: #c36460;
}

#idea-menu {
  position: absolute;
  top: 10px;
  left: 10px;
  width: calc(100% - 20px);
  height: calc(100% - 20px);
  background-color: #f1b093;
  color: #60433f;
  border: 2px solid #c36460;
  outline: 4px solid #d9806b;
  box-shadow: 0px 0px 0px 6px #6e4942;
  padding: 15px;
  box-sizing: border-box;
  display: none;
  z-index: 30;
  font-family: "Jersey 25", sans-serif;
}

#idea-menu h2 {
  margin: 0 0 10px 0;
  font-size: 20px;
  text-align: center;
  border-bottom: 2px dashed #c36460;
  padding-bottom: 5px;
}

#idea-list {
  /* list-style: square; */
  list-style-type: none;
  padding: 0;
  margin: 0;
  height: 70%;
  overflow-y: auto;
  font-family: "Jersey 10", sans-serif;
  font-size: 16px;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

#idea-list::-webkit-scrollbar {
  display: none;
}

#idea-list li {
  display: flex;
  align-items: flex-start;
  background-color: rgba(195, 100, 96, 0.15);
  border: 2px solid #c36460;
  border-bottom-width: 4px;
  padding: 10px;
  margin-bottom: 12px;
  gap: 10px;
}

.idea-portrait-box {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  background-color: #d9806b;
  border: 2px solid #c36460;
  display: flex;
  justify-content: center;
  align-items: center;
  image-rendering: pixelated;
}

.idea-portrait {
  max-width: 32px;
  max-height: 32px;
}

.idea-content {
  flex-grow: 1;
}

.idea-author {
  color: #8c3b38;
  font-family: "Jersey 25", sans-serif;
  font-size: 16px;
}

.idea-text {
  color: #60433f;
  line-height: 1.1;
}

.menu-instruction {
  position: absolute;
  bottom: 5px;
  left: 0;
  width: 100%;
  text-align: center;
  color: #c36460;
  font-size: 12px;
  margin: 0;
}

#game-world {
  width: 2048px;
  height: 2048px;
  background-color: #78C850;
  position: absolute;
  top: 0;
  left: 0;
  background-image: url("../img/map.png");
  background-repeat: no-repeat;
  /* filter:brightness(1); */
}

#tree-foreground {
  position: absolute;
  top: 0;
  left: 0;
  width: 2048px;
  height: 2048px;
  background-image: url("../img/trees-foreground.png");
  background-repeat: no-repeat;
  z-index: 20;
  pointer-events: none;
}

.sprite { width: 16px; height: 16px; position: absolute; }
#player {
  z-index: 10;
  background-image: url('../img/characters/old-man-idle-down.gif');
  background-size: cover;
}
.npc {z-index: 5; width: 20px; height: 20px;}

.invisible-block {
  background: transparent;
  position: absolute;
  z-index: 4;
}

#item-keps {background-image: url('../img/misc/hat.png'); background-size: cover; width: 16px; height: 16px; z-index: 4; top: 15px; left: 1880px;}
#item-halsband {background-image: url('../img/misc/necklace.png'); background-size: cover; width: 16px; height: 16px; z-index: 4; bottom: 240px; left: 50px;}
#item-computer {width: 128px; height: 72px; top: 325px; left: 1410px;}
/* #item-door {background-image: url('..img/misc/door-closed.png'); background-size: contain; width: 32px; height: 32px; top: 350px; left: 1430px; z-index: 5;} */
#item-door {background-image: url('../img/misc/door-closed.png'); background-size: contain; width: 32px; height: 32px; top: 368px; left: 1472px;}
#object-boat {background-image: url('../img/misc/boat.gif'); background-size: cover; width: 32px; height: 16px; top: 585px; left: 303px;}
#object-campfire {background-image: url('../img/misc/campfire.gif'); background-size: cover; width: 16px; height: 32px; top: 592px; left: 170px;}
#object-campfire-2 {background-image: url('../img/misc/campfire.gif'); background-size: cover; position: absolute; width: 16px; height: 32px; top: 1239px; left: 1252px;}
#object-board {width: 24px; height: 16px; top: 575px; left: 117px;}
#object-bridge-block {width:250px; height: 32px; top: 970px; left: 180px;}
#forest-top-left {width: 700px; height: 180px; top: 0px; left: 0px;}
#forest-top-left-small {width: 500px; height: 310px; top: 250px; left: 0px;}
#forest-right {width: 100px; height: 2048px; top: 0px; right: 0px;}
#forest-small-1 {width: 200px; height: 90px; top: 0px; right: 200px;}
#forest-small-2 {width: 120px; height: 100px; top: 0px; right: 600px;}
#forest-small-3 {width: 120px; height: 70px; top: 0px; right: 860px;}
#small-pond {width: 350px; height: 220px; bottom: 330px; right: 270px;}
#small-pond-2 {width: 180px; height: 250px; top: 840px; left: 0px;}
#small-pond-3 {width: 120px; height: 120px; top: 940px; left: 420px;}

#object-fountain {background-image: url('../img/misc/obj-fountain.gif'); background-size: contain; width: 30px; height: 32px; top: 980px; left: 1810px;}
#object-trashcan {width: 16px; height: 16px; top: 848px; left: 1728px;}
#object-coffeemug {background-image: url('../img/misc/obj-coffeemug.png'); background-size: contain; position: absolute; width: 8px; height: 8px; top: 1660px; left: 790px;}
#object-bottle {background-image: url('../img/misc/obj-bottle.png'); background-size: contain; position: absolute; width: 12px; height: 12px; top: 698px; left: 1465px; transform: rotate(32deg);}
#object-carrot {background-image: url('../img/misc/obj-carrot.png'); background-size: contain; position: absolute; width: 16px; height: 16px; top: 205px; left: 1567px;}
#object-barrel {background-image: url('../img/misc/obj-barrel.png'); background-size: contain; width: 16px; height: 16px; top: 1383px; left: 293px;}
/* #object-barrel {width: 16px; height: 16px; top: 363px; left: 1539px;} */
#anim-chicken {background-image: url('../img/characters/chicken.gif'); background-size: contain; width: 14px; height: 15px; top: 516px; left: 1549px; transform: scaleX(-1);}
#anim-cow {background-image: url('../img/characters/cow.gif'); background-size: contain; width: 25px; height: 15px; top: 1093px; left: 136px;}
#anim-goat {background-image: url('../img/characters/goat.gif'); background-size: contain; width: 17px; height: 13px; top: 43px; left: 1265px;}

#elev1 { top: 1000px; left: 300px; background-image: url('../img/characters/npc3.gif'); background-size: cover;}
#elev2 { top: 17px; left: 751px; background-image: url('../img/characters/npc2.gif'); background-size: cover;}
#elev-keps { top: 205px; left: 430px; background-image: url('../img/characters/npc1.gif'); background-size: cover;}
#elev4 { top: 770px; left: 450px; background-image: url('../img/characters/npc22.gif'); background-size: cover; transform: scaleX(-1);}
#elev5 { top: 950px; left: 1815px; background-image: url('../img/characters/npc5.gif'); background-size: cover;}
#elev6 { top: 1030px; left: 1820px; background-image: url('../img/characters/npc11.gif'); background-size: cover; transform: scaleX(-1);}
#elev7 { top: 1926px; left: 1865px; background-image: url('../img/characters/npc15.gif'); background-size: cover; transform: scaleX(-1);}
#elev8 { top: 2016px; left: 1345px; background-image: url('../img/characters/npc21.gif'); background-size: cover;}
#elev9 { top: 1856px; left: 475px; background-image: url('../img/characters/npc9.gif'); background-size: cover;}
#elev10 { top: 1416px; left: 30px; background-image: url('../img/characters/npc10.gif'); background-size: cover;}
#elev11 { top: 1306px; left: 660px; background-image: url('../img/characters/npc6.gif'); background-size: cover;}
#elev12 { top: 1366px; left: 1090px; background-image: url('../img/characters/npc12.gif'); background-size: cover;}
#elev13 { top: 306px; left: 1210px; background-image: url('../img/characters/npc13.gif'); background-size: cover; transform: scaleX(-1);}
#elev14 { top: 30px; left: 1503px; background-image: url('../img/characters/npc8.gif'); background-size: cover; transform: scaleX(-1);}
#elev15 { top: 380px; left: 1926px; background-image: url('../img/characters/npc7.gif'); background-size: cover; transform: scaleX(-1);}
#elev16 { top: 850px; left: 1465px; background-image: url('../img/characters/npc18.gif'); background-size: cover; transform: scaleX(-1);}
#elev17 { top: 1750px; left: 1535px; background-image: url('../img/characters/npc14.gif'); background-size: cover; transform: scaleX(-1);}
#elev18 { top: 450px; left: 835px; background-image: url('../img/characters/npc16.gif'); background-size: cover;}
/* #kollega { top: 982px; left: 966px; background-image: url('../img/characters/npc23.gif'); background-size: cover; width: 22px; height: 22px;} */
/* #kollega { top: 590px; left: 930px; background-image: url('../img/characters/npc23.gif'); background-size: contain; background-repeat: no-repeat; width: 12px; height: 23px; transform: scaleX(-1);} */
#kollega { top: 1250px; left: 1275px; background-image: url('../img/characters/npc23.gif'); background-size: contain; background-repeat: no-repeat; width: 12px; height: 23px; transform: scaleX(-1);}
/* #object-notebook { top: 600px; left: 912px; background-image: url('../img/misc/notebook.png'); background-size: cover; position: absolute; width: 12px; height: 12px;} */
#object-notebook { top: 1240px; left: 1265px; background-image: url('../img/misc/notebook.png'); background-size: contain; position: absolute; width: 12px; height: 12px;}
#object-tent { top: 1195px; left: 1195px; background-image: url('../img/misc/obj-tent.png'); background-size: cover; position: absolute; width: 37px; height: 50px;}

#dialog-box {
  position: absolute;
  bottom: 10px;
  left: 10px;
  width: 75%;
  height: 80px;
  background-color: #f1b093;
  color: #60433f;
  border: 2px solid #c36460;
  outline: 4px solid #d9806b;
  box-shadow: 0px 0px 0px 6px #6e4942;
  padding: 10px;
  box-sizing: border-box;
  display: none;
  z-index: 20;
  image-rendering: pixelated;
}

#dialog-portrait {
  position: absolute;
  left: 10px;
  top: 10px;
  width: 32px;
  height: 32px;
  border: 2px solid #c36460;
  outline: 3px solid #d9806b;
}

#dialog-name {
  position: absolute;
  /* top: -24px; */
  bottom: calc(100% + 2px);
  left: 8px;
  font-family: "Jersey 25", sans-serif;
  font-size: 14px;
  line-height: 1;
  background-color: #f1b093;
  color: #60433f;
  border: 2px solid #c36460;
  outline: 3px solid #d9806b;
  box-shadow: 0px 0px 0px 4px #6e4942;
  padding: 1px 6px;
}

#dialog-text {
  margin: 0;
  font-size: 16px;
  font-family: "Jersey 10", sans-serif;
  margin-left: 0px;
}

#dialog-box.has-portrait #dialog-text {
  margin-left: 45px;
}

.instruction {
  color: #c36460;
  font-size: 12px;
  position: absolute;
  bottom: 5px;
  right: 10px;
  margin: 0;
  font-family: "Jersey 25", sans-serif;
}

#credits-screen {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background-color: black;
  color: white;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 100;
  text-align: center;
  font-family: "Jersey 25", sans-serif;
}

#credits-screen h1 {
  color: #f4f8e4;
  text-shadow:
    2px 2px 0 #6b8dd2,
    -1px -1px 0 #6b8dd2,
    1px -1px 0 #476298,
    -1px 1px 0 #476298;
  margin-bottom: 10px;
  text-transform: uppercase;
}
#credits-screen p { font-size: 14px; margin: 5px 0; }

/* #6b8dd2,
#476298, */

.credits-wrapper {
  position: absolute;
  width: 100%;
  left: 0;
  top: 100%;
  animation: scroll-up 15s linear forwards;
}

@keyframes scroll-up {
  0% {
    top: 100%;
  }
  100% {
    top: 15%;
  }
}

#btn-restart {
  margin-top: 40px;
  font-family: "Jersey 10", monospace, sans-serif;
  color: #f4f8e4;
  background-color: transparent;
  border: 0;
  font-size: 20px;
  cursor: pointer;
  text-shadow: 1px 1px 0 #6b8dd2;

  /* text-shadow:
    2px 2px 0 #6b8dd2,
    -1px -1px 0 #6b8dd2,
    1px -1px 0 #476298,
    -1px 1px 0 #476298; */
}

/* Mobil-kontroller */
#controller-wrapper { display: none;}

/* ==========================================================================
   MOBILE & TABLET RESPONSIVE OVERHAUL
   ========================================================================== */
/* @media only screen and (max-width: 560px) { */
@media only screen and (max-width: 560px) and (orientation: portrait) and (pointer: coarse) {
  body {
    /* background: #dddddd; */
    background: #8e9eab;
    background: -webkit-linear-gradient(to bottom, #eef2f3, #8e9eab);
    background: linear-gradient(to bottom, #eef2f3, #8e9eab);
    background-attachment: fixed;
    height: auto;
    flex-direction: column;
    touch-action: manipulation;
    transform: none;
  }

  #camera {
    /* transform: scale(0.65); */
    width:320px;
    height: 280px;
    margin-top: 20px;
    border: 8px solid rgba(20, 20, 20, 0.9);
    border-bottom-width: 12px;
    box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.6);
    border-radius: 2px;
    outline: none;
  }

  #help-text {display: none;}

  #idea-list {font-size: 14px;}

  #dialog-box {
    height: 65px;
    padding: 8px;
    width: 94%;
  }

  #dialog-text {font-size: 14px;}

  #dialog-portrait {
    width: 32px;
    height: 32px;
  }

  #dialog-box.has-portrait #dialog-text {margin-left: 45px;}

  /* Mobil-kontroller */
  #controller-wrapper {
    position: fixed;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 30px;
  }

  .main-controls {
    display: flex;
    align-items: center;
    gap: 100px;
  }

  .start-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
  }

  #btn-start {
    width: 40px;
    height: 10px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    box-shadow: inset 1px 1px 1px 0 rgba(255, 255, 255, 0.1), 1px 1px 0px 0 rgba(0, 0, 0, 0.7);
    color: white;
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    cursor: pointer;
    transition-duration: 0.1s;
    -webkit-tap-highlight-color: transparent;
  }

  .start-container::after {
    content: "START";
    font-family: 'Press Start 2P', cursive;
    font-size: 8px;
    color: rgba(0, 0, 0, 0.2);
    margin-top: 5px;
  }

  #btn-start:active {
    box-shadow: none;
    transform: translate(1px, 1px);
  }

  .d-pad {
    display: grid;
    grid-template-columns: repeat(3, 50px);
    grid-template-rows: repeat(3, 50px);
    gap: 0px;
    justify-content: center;
    align-content: center;
    width: 160px;
    height: 160px;
    background: rgba(100, 100, 100, 0.1);
    box-shadow: inset 2px 2px 5px 0 rgba(100, 100, 100, 0.1);
    border-radius: 50%;
  }

  /* Grid Placement */
  .btn-up    { grid-column: 2; grid-row: 1; }
  .btn-left  { grid-column: 1; grid-row: 2; }
  .btn-right { grid-column: 3; grid-row: 2; }
  .btn-down  { grid-column: 2; grid-row: 3; }

  .btn {
    width: 50px;
    height: 50px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    box-shadow: inset 2px 2px 2px 0 rgba(255, 255, 255, 0.1), 1px 1px 0px 0 rgba(0, 0, 0, 0.7);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
    transition-duration: 0.1s;
    -webkit-tap-highlight-color: transparent;
  }

  .btn:active {
    box-shadow: none;
    transform: translate(1px, 1px);
  }

  #btn-action {
    width: 70px;
    height: 70px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    box-shadow: inset 2px 2px 2px 0 rgba(255, 255, 255, 0.1), 2px 2px 0px 0 rgba(0, 0, 0, 0.7);
    color: white;
    font-family: 'Press Start 2P', cursive;
    font-size: 20px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  #btn-action:active {
    transform: translate(2px, 2px);
    box-shadow: none;
  }
}

/* ==========================================================================
   MOBILE LANDSCAPE OVERHAUL (FULLY STYLED GBA / SWITCH LAYOUT)
   ========================================================================== */
@media screen and (orientation: landscape) and (max-height: 560px) and (pointer: coarse) {
  body {
    background: linear-gradient(to bottom, #eef2f3, #8e9eab);
    height: 100vh;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    touch-action: manipulation;
    transform: none;
  }

  #camera {
    width: 384px;
    height: 256px;
    border: 8px solid rgba(20, 20, 20, 0.9);
    border-bottom-width: 12px;
    box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.6);
    border-radius: 2px;
    margin: 0;
    z-index: 1;
    position: absolute;
    top: 20px;
  }

  #help-text {display: none;}

  #idea-list {font-size: 14px;}

  /* Compact dialog optimization for tight landscape heights */
  #dialog-box {
    width: 94%;
    height: 70px;
    bottom: 8px;
    left: 3%;
  }

  #dialog-text {font-size: 14px;}

  #dialog-portrait {
    width: 32px;
    height: 32px;
  }

  #dialog-box.has-portrait #dialog-text {margin-left: 45px;}

  /* Full screen wrapper for mobile layout */
  #controller-wrapper {
    display: flex !important;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    flex-direction: row;
    pointer-events: none; /* Let touches pass through empty areas */
    z-index: 10;
    transform: none;
    padding: 0;
    margin: 0;
  }

  /* Push D-Pad left and Action button right */
  .main-controls {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    padding-left: 1%;
    padding-right: 6%;
    pointer-events: none;
    gap: 0;
  }

  /* --- D-PAD STYLING --- */
  .d-pad {
    display: grid !important;
    grid-template-columns: repeat(3, 50px);
    grid-template-rows: repeat(3, 50px);
    gap: 0px;
    justify-content: center;
    align-content: center;
    width: 160px;
    height: 160px;
    background: rgba(100, 100, 100, 0.1);
    box-shadow: inset 2px 2px 5px 0 rgba(100, 100, 100, 0.1);
    border-radius: 50%;
    pointer-events: auto;
    transform: scale(0.85); /* Slightly scaled down to fit landscape screen heights */
  }

  /* Grid Placement */
  .btn-up    { grid-column: 2; grid-row: 1; }
  .btn-left  { grid-column: 1; grid-row: 2; }
  .btn-right { grid-column: 3; grid-row: 2; }
  .btn-down  { grid-column: 2; grid-row: 3; }

  /* Base Button Aesthetic */
  .btn {
    width: 50px;
    height: 50px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    box-shadow: inset 2px 2px 2px 0 rgba(255, 255, 255, 0.1), 1px 1px 0px 0 rgba(0, 0, 0, 0.7);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
    transition-duration: 0.1s;
    -webkit-tap-highlight-color: transparent;
  }

  .btn:active {
    box-shadow: none;
    transform: translate(1px, 1px);
  }

  /* --- ACTION (A) BUTTON STYLING --- */
  #btn-action {
    width: 70px;
    height: 70px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    box-shadow: inset 2px 2px 2px 0 rgba(255, 255, 255, 0.1), 2px 2px 0px 0 rgba(0, 0, 0, 0.7);
    color: white;
    font-family: 'Press Start 2P', cursive;
    font-size: 20px;
    cursor: pointer;
    pointer-events: auto;
    -webkit-tap-highlight-color: transparent;
    transform: scale(0.9);
  }

  #btn-action:active {
    transform: scale(0.9) translate(2px, 2px);
    box-shadow: none;
  }

  /* --- START BUTTON STYLING --- */
  .start-container {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    position: fixed;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: auto;
  }

  #btn-start {
    width: 40px;
    height: 10px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    box-shadow: inset 1px 1px 1px 0 rgba(255, 255, 255, 0.1), 1px 1px 0px 0 rgba(0, 0, 0, 0.7);
    color: white;
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    cursor: pointer;
    transition-duration: 0.1s;
    -webkit-tap-highlight-color: transparent;
  }

  .start-container::after {
    content: "START";
    font-family: 'Press Start 2P', cursive;
    font-size: 8px;
    color: rgba(0, 0, 0, 0.2);
    margin-top: 3px;
  }

  #btn-start:active {
    box-shadow: none;
    transform: translate(1px, 1px);
  }
}

/* ==========================================================================
   TABLET & IPAD OVERHAUL (FULLY STYLED PORTRAIT & LANDSCAPE)
   ========================================================================== */

@media screen and (pointer: coarse) and (min-width: 561px) {
  /* ------------------------------------
     SHARED RETRO CONTROLLER AESTHETICS
     ------------------------------------ */

   /* Push D-Pad left and Action button right */
   .main-controls {
     display: flex !important;
     justify-content: space-between;
     align-items: center;
     width: 100%;
     height: 100%;
     box-sizing: border-box;
     padding-left: 2% !important;
     padding-right: 6%;
     pointer-events: none;
     gap: 0;
   }

   /* --- D-PAD STYLING --- */
   .d-pad {
     display: grid !important;
     grid-template-columns: repeat(3, 50px);
     grid-template-rows: repeat(3, 50px);
     gap: 0px;
     justify-content: center;
     align-content: center;
     width: 160px;
     height: 160px;
     background: rgba(100, 100, 100, 0.1);
     box-shadow: inset 2px 2px 5px 0 rgba(100, 100, 100, 0.1);
     border-radius: 50%;
     pointer-events: auto;
     transform: scale(0.85) !important; /* Slightly scaled down to fit landscape screen heights */
   }

  .btn {
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    box-shadow: inset 2px 2px 2px 0 rgba(255, 255, 255, 0.1), 1px 1px 0px 0 rgba(0, 0, 0, 0.7);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
    transition-duration: 0.1s;
    -webkit-tap-highlight-color: transparent;
  }

  .btn:active {
    box-shadow: none;
    transform: translate(1px, 1px); /* Accounts for d-pad base scaling */
  }

  #btn-action {
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    box-shadow: inset 2px 2px 2px 0 rgba(255, 255, 255, 0.1), 2px 2px 0px 0 rgba(0, 0, 0, 0.7);
    color: white;
    font-family: 'Press Start 2P', cursive;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  #btn-start {
    width: 40px;
    height: 10px;
    background: rgba(0, 0, 0, 0.6);
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 10px;
    box-shadow: inset 1px 1px 1px 0 rgba(255, 255, 255, 0.1), 1px 1px 0px 0 rgba(0, 0, 0, 0.7);
    color: white;
    font-family: 'Press Start 2P', cursive;
    font-size: 10px;
    cursor: pointer;
    transition-duration: 0.1s;
    -webkit-tap-highlight-color: transparent;
  }

  #btn-start:active {
    box-shadow: none;
    transform: translate(1px, 1px);
  }

  .start-container::after {
    content: "START";
    font-family: 'Press Start 2P', cursive;
    font-size: 8px;
    color: rgba(0, 0, 0, 0.2);
    margin-top: 5px;
  }
}

/* ------------------------------------
   1. IPAD PORTRAIT CONFIGURATION
   ------------------------------------ */
@media screen and (pointer: coarse) and (min-width: 561px) and (orientation: portrait) {
  body {transform: none;}
  #help-text {display: none;}

  /*
  body {
    flex-direction: column;
    background: linear-gradient(to bottom, #eef2f3, #8e9eab);
    justify-content: flex-start;
    padding-top: 40px;
    height: auto;
    touch-action: manipulation;
    transform: none;
  }

  #camera {
    width: 480px;
    height: 320px;
    border: 10px solid rgba(20, 20, 20, 0.9);
    border-radius: 6px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    margin: 0 auto;
  }

  #controller-wrapper {
    display: flex !important;
    position: relative;
    bottom: auto;
    left: auto;
    transform: none;
    margin-top: 50px;
    flex-direction: column;
    align-items: center;
    gap: 40px;
    pointer-events: auto;
  }

  .main-controls {
    display: flex !important;
    gap: 140px;
  }

  .d-pad {
    display: grid !important;
    grid-template-columns: repeat(3, 50px);
    grid-template-rows: repeat(3, 50px);
    width: 160px;
    height: 160px;
    background: rgba(100, 100, 100, 0.1);
    box-shadow: inset 2px 2px 5px 0 rgba(100, 100, 100, 0.1);
    border-radius: 50%;
    transform: scale(1.1);
  }

  .btn-up    { grid-column: 2; grid-row: 1; }
  .btn-left  { grid-column: 1; grid-row: 2; }
  .btn-right { grid-column: 3; grid-row: 2; }
  .btn-down  { grid-column: 2; grid-row: 3; }

  #btn-action {
    width: 70px;
    height: 70px;
    font-size: 20px;
    transform: scale(1.15);
  }

  #btn-action:active {
    transform: scale(1.15) translate(2px, 2px);
    box-shadow: none;
  }

  .start-container {
    display: flex !important;
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: auto;
    flex-direction: column;
    gap: 5px;
  }

  */
}

/* ------------------------------------
   2. IPAD LANDSCAPE CONFIGURATION
   ------------------------------------ */
@media screen and (pointer: coarse) and (min-height: 561px) and (orientation: landscape) {
  body {
    background: linear-gradient(to bottom, #eef2f3, #8e9eab);
    overflow: hidden;
    height: 100vh;
    margin: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    touch-action: manipulation;
    transform: none;
  }

  #camera {
    width: 576px;
    height: 384px;
    border: 8px solid rgba(20, 20, 20, 0.9);
    border-bottom-width: 12px;
    box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.6);
    border-radius: 2px;
    z-index: 1;
    margin: 0;
  }

  #help-text {
    display: none;
  }

  #controller-wrapper {
    display: flex !important;
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    flex-direction: row;
    pointer-events: none;
    z-index: 10;
    transform: none;
    padding: 0;
    margin: 0;
  }

  .main-controls {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    padding: 0 5%;
    pointer-events: none;
    gap: 0;
  }

  .d-pad {
    display: grid !important;
    grid-template-columns: repeat(3, 60px);
    grid-template-rows: repeat(3, 60px);
    width: 190px; height: 190px;
    pointer-events: auto;
    transform: scale(1.1);
    background: rgba(100, 100, 100, 0.1);
    box-shadow: inset 2px 2px 5px 0 rgba(100, 100, 100, 0.1);
    border-radius: 50%;
  }

  .btn { width: 60px; height: 60px; }
  .btn-up    { grid-column: 2; grid-row: 1; }
  .btn-left  { grid-column: 1; grid-row: 2; }
  .btn-right { grid-column: 3; grid-row: 2; }
  .btn-down  { grid-column: 2; grid-row: 3; }

  #btn-action {
    width: 85px;
    height: 85px;
    font-size: 24px;
    pointer-events: auto;
    transform: scale(1.1);
  }

  #btn-action:active {
    transform: scale(1.1) translate(2px, 2px);
    box-shadow: none;
  }

  .start-container {
    display: flex !important;
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: auto;
    flex-direction: column;
    align-items: center;
    gap: 5px;
  }
}
