@import "https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap";

/* src/style/base.css */
:root {
  --background-guide-image: url("https://s3.ap-southeast-1.amazonaws.com/cherrytreefriends.com/transparent_grid_guide_cell_ids_ttf.png");
}

*, *:before, *:after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  overflow: hidden;
  background-color: #f3f4f6;
  height: 100%;
  font-family: Inter, sans-serif;
}

.env-mobile-browser #text-input-container {
  margin-bottom: 60px;
}

#app-container {
  display: flex;
  position: relative;
  background-color: #f3f4f6;
  flex-direction: column;
  width: 100%;
  height: 100%;
}

#top-bar {
  display: flex;
  z-index: 20;
  background-color: #f3f4f6;
  border-bottom: 1px solid #e5e7eb;
  flex-shrink: 0;
  justify-content: space-between;
  align-items:  center;
  width: 100%;
  padding: 10px 15px;
}

#burger-icon {
  display: flex;
  cursor: pointer;
  opacity: .6;
  position: relative;
  box-sizing: border-box;
  border-top: 3px solid #6b7280;
  border-bottom: 3px solid #6b7280;
  flex-direction: column;
  justify-content: space-between;
  width: 30px;
  height: 22px;
  padding: 2px 0;
}

#burger-icon:before {
  content: "";
  position: absolute;
  background-color: #6b7280;
  border-radius: 3px;
  width: 100%;
  height: 3px;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
}

#burger-icon:hover {
  opacity: 1;
}

#device-select {
  cursor: pointer;
  background-color: #fff;
  border: 1px solid #d1d5db;
  border-radius: 4px;
  margin: 0 10px;
  padding: 5px 8px;
  font-size: .85rem;
}

#toggle-button {
  color: #374151;
  cursor: pointer;
  background-color: #e5e7eb;
  border: 1px solid #9ca3af;
  border-radius: 4px;
  padding: 5px 10px;
  transition: background-color .2s;
  font-size: .85rem;
}

#toggle-button:hover {
  background-color: #d1d5db;
}

#main-content {
  overflow: hidden;
  position: relative;
  overflow-anchor: none;
  background-color: #e0f2fe;
  background-image: var(--background-guide-image);
  z-index: 0;
  display: flex;
  background-position: center;
  background-repeat: no-repeat;
  background-size: 2048px 2048px;
  flex-direction: column;
  flex-grow: 1;
  width: 100%;
  padding: 15px;
}

#text-output {
  position: relative;
  z-index: 2;
  overflow-y: auto;
  color: #1f2937;
  word-wrap: break-word;
  background-color: #ffffffe6;
  border: 1px solid #d1d5dbcc;
  border-radius: 6px;
  flex-shrink: 0;
  min-height: 50px;
  max-height: 200px;
  margin: 0 0 15px;
  padding: 10px;
  font-family: Inter, sans-serif;
  font-size: .95rem;
  box-shadow: inset 0 1px 2px #0000000d;
}

#text-output > div {
  border-bottom: 1px dashed #e5e7eb;
  margin-bottom: 6px;
  padding-bottom: 6px;
}

#text-output > div:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

#game-canvas {
  position: relative;
  z-index: 1;
  background-color: #0000;
  flex-grow: 1;
  width: 100%;
}

#text-input-container {
  z-index: 15;
  background-color: #e5e7eb;
  border-top: 1px solid #d1d5db;
  flex-shrink: 0;
  width: 100%;
  padding: 10px 15px;
  transition: margin-bottom .3s ease-in-out;
  box-shadow: 0 -1px 3px #0000000d;
}

#text-input {
  color: #1f2937;
  outline: none;
  background-color: #fff;
  border: 1px solid #9ca3af;
  border-radius: 20px;
  width: 100%;
  padding: 10px 15px;
  transition: border-color .2s, box-shadow .2s;
  font-size: 1rem;
}

#text-input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px #3b82f64d;
}

#text-input, #text-output {
  user-select: text;
  -webkit-user-select: text;
  -moz-user-select: text;
  -ms-user-select: text;
}

::selection {
  color: #fff;
  background-color: #3b82f6;
}

::selection {
  color: #fff;
  background-color: #3b82f6;
}

@media (min-width: 768px) {
  #main-content {
    padding: 20px;
  }

  #text-output {
    max-height: 300px;
    margin: 0 0 20px;
    font-size: 1rem;
  }

  #text-input-container {
    padding: 15px 20px;
  }

  #text-input {
    padding: 12px 18px;
    font-size: 1rem;
  }
}

/* src/style/controls.css */
.touch-controls-container {
  position: absolute;
  display: flex;
  z-index: 5;
  pointer-events: none;
  opacity: 1;
  visibility: visible;
  justify-content: space-between;
  align-items:  center;
  height: 105px;
  padding: 0;
  transition: opacity .3s ease-in-out, visibility linear, bottom .3s ease-in-out;
  bottom: 75px;
  left: 15px;
  right: 15px;
}

.touch-controls-container.controls-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .3s ease-in-out, visibility 0s linear .3s, bottom .3s ease-in-out;
}

.touch-controls-container:not(.controls-hidden) {
  transition: opacity .3s ease-in-out, visibility linear, bottom .3s ease-in-out;
}

.env-mobile-browser .touch-controls-container {
  bottom: 125px;
}

.joystick-container {
  position: relative;
  display: flex;
  opacity: .8;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  -webkit-touch-callout: none;
  cursor: grab;
  pointer-events: auto;
  flex-shrink: 0;
  justify-content: center;
  align-items:  center;
  width: 105px;
  height: 105px;
  transition: width .2s, height .2s;
}

.joystick-container:has(.joystick-handle.active) {
  cursor: grabbing;
}

.joystick-base {
  position: absolute;
  pointer-events: none;
  background-color: #e5e7eb80;
  border: 2px solid #9ca3af80;
  border-radius: 50%;
  width: 100%;
  height: 100%;
  top: 0;
  left: 0;
  box-shadow: inset 0 0 10px #0000001a;
}

.joystick-handle {
  position: absolute;
  z-index: 5;
  pointer-events: none;
  will-change: transform;
  background-color: #6b7280b3;
  border: 1px solid #374151b3;
  border-radius: 50%;
  width: 35px;
  height: 35px;
  transition: transform .1s linear, width .2s, height .2s, background-color .1s;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 2px 5px #0003;
}

.joystick-handle.active {
  background-color: #4b5563cc;
  transition: none;
  box-shadow: 0 4px 8px #0000004d;
}

.action-button-container {
  position: relative;
  opacity: .8;
  pointer-events: auto;
  display: flex;
  flex-shrink: 0;
  justify-content: space-between;
  align-items:  center;
  width: 90px;
  height: 105px;
  transition: width .2s, height .2s;
}

.control-button {
  position: absolute;
  display: flex;
  color: #ffffffe6;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  pointer-events: auto;
  border: 1px solid #0000001a;
  border-radius: 50%;
  justify-content: center;
  align-items:  center;
  width: 50px;
  height: 50px;
  transition: transform 50ms, background-color .1s, width .2s, height .2s, font-size .2s;
  font-size: 1.1rem;
  font-weight: bold;
  box-shadow: 0 2px 4px #00000026;
}

.button-b {
  background-color: #3b82f699;
  bottom: 0;
  left: 0;
}

.button-b:hover {
  background-color: #2563ebb3;
}

.button-a {
  background-color: #ef444499;
  top: 0;
  right: 0;
}

.button-a:hover {
  background-color: #dc2626b3;
}

.control-button.active {
  transform: scale(.95);
  box-shadow: inset 0 1px 3px #0003;
}

.button-a.active {
  background-color: #dc2626b3;
}

.button-b.active {
  background-color: #2563ebb3;
}

@media (min-width: 768px) {
  .touch-controls-container {
    height: 120px;
    bottom: 85px;
    left: 20px;
    right: 20px;
  }

  .joystick-container {
    width: 120px;
    height: 120px;
  }

  .joystick-handle {
    width: 40px;
    height: 40px;
  }

  .action-button-container {
    width: 110px;
    height: 120px;
  }

  .control-button {
    width: 60px;
    height: 60px;
    font-size: 1.2rem;
  }
}
